Skip to main content

Maximum Deviation Moving Average for Amibroker (AFL)

lel4866 almost 13 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 2)
  • Tags:
    amibroker

This is an exponential moving average which adjusts its self to maintain a minimum percentage deviation from the last close. This allows you to use slower moving averages to better smooth price without having to wait excessively long for a signal to occur when price reverses.

Of course you could use of variety of ema based averages rather than the standard ema used here.

Indicator / Formula

Copy & Paste Friendly
// maximum deviation EMA
Per = Param("EMA Period", 22, 1, 900, 1);
MaxDev = Param("Max Deviation", 1.0, 0.0, 99.0);
alpha = 2.0/(1.0 + Per);
one_minus_alpha = 1.0 - alpha;
last_avgema = C[0];
avgema[0] = last_avgema;
for (i=1; i<BarCount; i++)
{
	ci = C[i];
	last_avgema = alpha*ci + one_minus_alpha*last_avgema;
	if (MaxDev > 0.0) {
		pctdev = 100.0*(ci - last_avgema)/ci;
    	if (pctdev >= 0.0)
    	{
        	if (pctdev > MaxDev)
            	last_avgema = ci - .01*MaxDev*ci;
    	}
    	else
    	{
        	if (-pctdev > MaxDev)
            	last_avgema = ci + .01*MaxDev*ci;
    	}
	}
	avgema[i] = last_avgema;
}

Plot( avgema, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 

13 comments

almost 13 years ago

if u r really interested to see any result of this code then u need to use the value of MaxDev <=1. above one it wont produce any different results than tht off normal MA.
so plz change the line 2 of code with

MaxDev = Param(“Max Deviation”, 0.5, 0, 1,0.0001);

2. lel4866
almost 13 years ago

You are correct that a value of 0 results in a standard ema. However, I specifically left 0 as a possible value, so that when optimizing, one of the possibilities is a standard ema.

almost 13 years ago

Dear,I want show result of this plz give me u r emailId
this is very gooooooooooooooooooooooooooooooooooooooood

almost 13 years ago

Plz note from 1st April to 9/4/13 Profit 1556 Points Last Buy signal come @ 5392 As on 9/4/13 Now today 5905 running profit 513. Means 1556 + 513 = 2069 points in just 5 months and 10 days. Also Note this figure carry stop los.

almost 13 years ago

prathjoshi

how do you trade using this system? if you can share here some details like which emas do you use, which time frame do you use etc.? you can also send me details on my email id “sutharnehal@gmail.com”. thanks in advance.

7. casoni
over 12 years ago

Hello prathjoshi
can you please show us your buy-sell conditions

as you said = msg no4
[ Plz note from 1st April to 9/4/13 Profit 1556 Points Last Buy signal come @ 5392 As on 9/4/13 Now today 5905 running profit 513. Means 1556 + 513 = 2069 points in just 5 months and 10 days. Also Note this figure carry stop los. ]
Thank you

over 12 years ago

Yes sir,

But I want more research, I want back dated data if any body have a last 1 or 2 year amibroker data plz give me.

& see result plz give e-mail ID.

Current profit 2041 points from april to 7/10/13, todays buy @ 5934 @ 2.59.59

One again I request plz give back dated amibroker intra day data for more study.

Thanks in advance.

10. casoni
over 12 years ago

Download 5min IEOD [01 april 2012 to 06 Oct 2013 ] of Nifty-1 , from
http://www.megafileupload.com/en/file/458636/NIFTY-1-txt.html
thank you

over 12 years ago

@prathjoshi or @casoni : could u please please post a screen shot of the chart with the above AFL please?

over 12 years ago

thx @casoni

btw use this link for all kinds of data in indian stock market. @prathjoshi

http://www.tradewithme.me/data-archives-for-technical-analysts.html

Leave Comment

Please login here to leave a comment.