Page 1 of 1

Hull Moving Average Trading System

Posted: 06 Nov 2007
by wajodi
Hi, Has anyone heard of this system? I would like to try it out, apparently it's based around a low lag Weighted Moving Average. I wrote to Alan Hull the original author of this moving average indicator and his reply is copied below.
Stanley do you think you could code it for me based on what Alan says in his email?, (shown below) I'm also attaching the PDF file Alan Hull sent to me in this email. I've also located some code written on another forum for MT I'm not sure if it will help but I'm attaching it in an TXT file also.

Thanks, hope you can assist me....... Wajodi

Email from Alan Hull Follows:
Hi Wayne

We only provide the intellectual property which is the attached article and it is up to the software providers to add it in to their products - I would suggest that you go back to your own software provider, Multi Charts, and ask if they will upgrade their program using the attached PDF article as a guide....

Regards,
Alan

ActVest Pty Ltd
ACN: 101 040 939
http://www.alanhull.com
Ph: +613 9778 7061
Fax: +613 9778 7062

Posted: 08 Nov 2007
by SP
This is the code from atavachron from the TS forum:

Function: jtHMA

Code: Select all

{jtHMA - Hull Moving Average Function}
{Author: Atavachron}
{May 2005}

Inputs: price(NumericSeries), length(NumericSimple);
Vars: halvedLength(0), sqrRootLength(0);

{
Original equation is:
---------------------
waverage(2*waverage(close,period/2)-waverage(close ,period), SquareRoot(Period)
Implementation below is more efficient with lengthy Weighted Moving Averages.
In addition, the length needs to be converted to an integer value after it is halved and
its square root is obtained in order for this to work with Weighted Moving Averaging
}

if ((ceiling(length / 2) - (length / 2)) <= 0.5) then
halvedLength = ceiling(length / 2)
else
halvedLength = floor(length / 2);

if ((ceiling(SquareRoot(length)) - SquareRoot(length)) <= 0.5) then
sqrRootLength = ceiling(SquareRoot(length))
else
sqrRootLength = floor(SquareRoot(length));

Value1 = 2 * WAverage(price, halvedLength);
Value2 = WAverage(price, length);
Value3 = WAverage((Value1 - Value2), sqrRootLength);

jtHMA = Value3;
Indicator:

Code: Select all

{jtHMA - Hull Moving Average Indicator}
{Author: Atavachron}
{May 2005}

{
Inputs:
-------
price: the time series being smoothed, usually Close, High, etc,
but could be RSI(Close, 25) for example.
length: the length of the MA, pretty meaningless in the normal sense
of moving averages, as this quantity is heavily modified
in the code. You need to experiment, do not just use a setting
of 20 because that is what works for you with Simple Moving Averages.
zeroLine: if you are using this in an indicator pane, you might
want to display a centre line of some sort, ths allows
one to set its value
zeroVisible: boolean variable, determines whether the centre line
(zeroLine) is plotted.
upColour: If you wish to differentiate upward movements by colour coding.
downColour: If you wish to differentiate downward movements by colour coding.
colourDeltaBar: Set this to 1 if you wish the colour change to be effective on
the actual bar where the direction change occurred.
Set this to 0 for default behaviour. All other values
are pretty meaningless.
}

Inputs: price(Close), length(21),
zeroLine(0.0), zeroVisible(false),
upColour(Blue), downColour(Red), colourDeltaBar(1);

Value1 = jtHMA(price, length);

Plot1(Value1, "jtHMA");

If ZeroVisible = true then
Plot2(zeroLine, "Zero");

{ Color criteria }
if (Value1 > Value1[1]) then
SetPlotColor[colourDeltaBar](1, upColour)
else if (Value1 < Value1[1]) then
SetPlotColor[colourDeltaBar](1, downColour);
Strategy

Code: Select all

{ jtHMA strategy }

inputs: price(Close), jthmaLength( 21 ), upColour(Blue), downColour(Red);
variables: Avg(0), colour(0);

Avg = jthma( price, jthmaLength ) ;

if Avg > Avg[1] then colour = upColour;
if Avg < Avg[1] then colour = downColour;


{buy sell Criteria}

if colour[1] <> colour then
if colour = upColour then
Buy ( "jup" ) next bar at market ;

if colour[1] <> colour then
if colour = downColour then
sell short ( "jdn" ) next bar at market ;


I cant compile this. pls help

Posted: 11 Dec 2007
by itai007
could some1 post an actual code attachment to be downloaded and imported ?

Thanks
Itai

Re: Hull Moving Average Trading System

Posted: 27 Jan 2011
by Laurent
The original version coded quickly, hope it helps.

Code: Select all

inputs:
DataValue ( NumericSeries ),
Length ( NumericSimple ) ;

Value1 = 2 * WAverage( DataValue, Length / 2 ) ;
Value2 = WAverage( DataValue, Length ) ;
Value3 = WAverage( Value1 - Value2, SquareRoot(Length) );

HMA = Value3 ;

Re: Hull Moving Average Trading System

Posted: 03 Jun 2011
by vetrader
Hi
I tried to compile the code given above but they all gave me errors (both function and indicator)....can someone help?

For the function i get this msg:
------ Compiled with error(s): ------
assignment is allowed only for variables or array elements
errLine 20, errColumn 0, errLineEnd 20, errColumnEnd 0

So for the indicator, i get an unknown function.....

Thanks
vetrader

Re: Hull Moving Average Trading System

Posted: 03 Jun 2011
by TJ
Hi
I tried to compile the code given above but they all gave me errors (both function and indicator)....can someone help?

For the function i get this msg:
------ Compiled with error(s): ------
assignment is allowed only for variables or array elements
errLine 20, errColumn 0, errLineEnd 20, errColumnEnd 0

So for the indicator, i get an unknown function.....

Thanks
vetrader
did you compile the function as a function?


ps. you need to compile the function before compiling the indicator.

Re: Hull Moving Average Trading System

Posted: 03 Jun 2011
by TJ
for those who are interested in different renditions of moving averages,
here's a collection to fuel your research:
look under Moving Averages & Trend Followers
http://www.tradersxchange.com/

Re: Hull Moving Average Trading System

Posted: 03 Jun 2011
by vetrader
Thks for the quick reply, TJ

Yes, i compiled it as a function. The full error msg:

------ Build started: ------
Study: "HMA" (Function)
Please wait ....
------ Compiled with error(s): ------
assignment is allowed only for variables or array elements
errLine 31, errColumn 0, errLineEnd 31, errColumnEnd 0

Re: Hull Moving Average Trading System

Posted: 03 Jun 2011
by TJ
Thks for the quick reply, TJ

Yes, i compiled it as a function. The full error msg:

------ Build started: ------
Study: "HMA" (Function)
Please wait ....
------ Compiled with error(s): ------
assignment is allowed only for variables or array elements
errLine 31, errColumn 0, errLineEnd 31, errColumnEnd 0
you have to compile it with the name "jtHMA" .

Re: Hull Moving Average Trading System

Posted: 03 Jun 2011
by vetrader
solved! Thks for your help, TJ!