[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Simple Moving Average Bands



PureBytes Links

Trading Reference Links




We may create a channel around M=MA(C,20), if we consider MUP 
+20% above M and MDOWN -20% below M.
For the last 100 bars, the percentage of bars inside the 
channel is INS %.
For many stocks this +20% is wide enough to give INS=100% and 
does not help.
Let us risk to decrease this 20% to obtain a NEWINS=95%. We 
will see, for many stocks, values below 10%, which gives more 
reasonable and useful MA channels.
When the small green circle appears, we should expect prices 
to move towards the MA again.
 
// Adjusted Moving Average Bands
P=20; 
LOOKBACK=100;
PERC=95;M=MA(C,P);
<FONT 
size=2>X=2;MUP=M*(1+X/10);MDOWN=M*(1-X/10);INS0=100*Sum(C>=MDOWN AND 
C<=MUP,LOOKBACK)/LOOKBACK;STEP=0.01;for(X=0.1;X<3;X=X+STEP){MUP=M*(1+X/10);MDOWN=M*(1-X/10);INS=100*Sum(C>=MDOWN 
AND 
C<=MUP,LOOKBACK)/LOOKBACK;G[0]=2;if(INS[BarCount-1]<=PERC){G=X;}}NEWMUP=M*(1+G/10);NEWMDOWN=M*(1-G/10);NEWINS=100*Sum(C>=NEWMDOWN 
AND 
C<=NEWMUP,LOOKBACK)/LOOKBACK;Plot(C,"",1,64);F=Cum(1)>LastValue(Cum(1))-LOOKBACK;Plot(M,"",1,1);Plot(MUP,"",2,1);Plot(MDOWN,"",2,1);Plot(NEWMUP,"",4,1);Plot(NEWMDOWN,"",4,1);Title=Name()+",Width="+WriteVal(10*G,1.1)+"%, 
OLD INS="+WriteVal(INS0,1.0)+"%"+", NEW 
INS="+WriteVal(NEWINS,1.0)+"%";PlotShapes((Cum(1)==LastValue(Cum(1))-LOOKBACK)*shapeUpTriangle,colorBlue);OUT=C<NEWMDOWN 
OR 
C>NEWMUP;PlotShapes(F*OUT*shapeSmallCircle,colorBrightGreen);Filter=Sum(OUT,3)>=1;// 
EXPLORE FOR THE N=1 LAST QUOTATIONS
AddColumn(10*g,"WIDTH 
%");AddColumn(C,"C");AddColumn(NEWMUP,"NEWMUP");AddColumn(NEWMDOWN,"NEWMDOWN");
 
For Indicator builder set scaling to Automatic.
For AA, explore for the n=1 last quotations to investigate if 
some green circle appeared the last 3 bars.
The initial Width 20% is too much for the majority of stocks. 
AAPL is responsible for this choice : the OLDINS is 93% and 
AAPL needs a new Width 24% to give the 95% !!! May2003 is 
still included in the 100-bar test period and causes this 
behavior. If AAPL is cool the next 15 bars, the Width will 
become more reasonable and useful for price speculation.
The N100 champion was NVDA. It needs a Width=29% [!!!] and 
does not like this method.
See the various Widths by replacing the filter condition to 
Filter=1; Many stocks are below 10% .
Dimitris Tsokakis
PS1. The formula is not proper for backtesting.
PS2. For more accurate results you may decrease the 
STEP=0.01, to STEP=0.005; or even to STEP=0.001; with the
unavoidable slow down of the 
procedure .






Yahoo! Groups Sponsor


  ADVERTISEMENT 









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Attachment:
MAbands.gif

Attachment: Description: "Description: GIF image"