Dynamic Moving Average Cross Over EasyLanguage

I had a request recently to publish the EasyLanguage code for my Dynamic Moving Average system.  This system tries to solve the problem of using an appropriate length moving average that will keep you out of the chop.  The adaptive engine utilizes market volatility and increases moving average lengths as volatility increases and decreases moving average lengths as volatility decreases.  Its had some success, but the adaptive engine has not truly solved the problem.  The logic is pretty straightforward and can be modified to use different types of adaptive engines.

{Dynamic Moving AVerage System by George Pruitt}
{Use volatility to adapt moving average lenghts}
{in hopes to outperform a static parameter set!}

vars: avg1Ceil(23),avg1Floor(9),avg2Ceil(100),avg2Floor(25);

vars: shortMALen(19),longMALen(29);
vars: x1(0),y1(0),x2(0),y2(0),deltaVol1(0),deltaVol2(0);


If barNumber = 1 then
Begin
shortMALen = 19;
longMALen = 29;
end;

x1 = Stddev(close,shortMALen);
y1 = Stddev(close[1],shortMALen);

x2 = Stddev(close,longMALen);
y2 = Stddev(close[1],longMALen);



deltaVol1 = (x1-y1)/y1;
deltaVol2 = (x2-y2)/y2;


shortMALen = (1+deltaVol1)*shortMALen;
shortMALen = MaxList(shortMALen,avg1Floor);
shortMALen = MinList(shortMALen,avg1Ceil);
shortMALen = round(shortMALen,0);

longMALen = (1+deltaVol2)*longMALen;
longMALen = MaxList(longMALen,avg2Floor);
longMALen = MinList(longMALen,avg2Ceil);
longMALen = round(longMALen,0);

If average(c,shortMALen) crosses above average(c,longMALen) then buy next bar at open;
If average(c,shortMALen) crosses below average(c,longMALen) then sellshort next bar at open;

Discover more from George Pruitt

Subscribe to get the latest posts sent to your email.

Leave a Reply