Monday, 9 September 2013

Amibroker AFL for positional trading


Today I am posting another AFL for the benefit of delivery based traders. This AFL can indicate or make sure you are on the safer side of the market. When this AFL is plotted one can observe colored dots appearing at the end of a trend. The white dot alerts us that new high or new lows are being formed. One can use this alert to exit with profit or enter short. The red dot signals a ongoing downtrend. Similarly a green dot tells us that the uptrend is intact.

There are two lines indicating MA High and Low. if these lines are plotted on a weekly chart one can have a better understanding of the stock in question. If the stock price moves down touching the Lower line and forms a green dot this is certainly a good buy for a medium term, say 2 or 3 weeks. when the stock price moves well above the upper line continues to give red dots as alerts, it safe to book your profits.

I am not the creator of this AFL, therefore the credit goes to the original creator of this trading system.

 /////////////////Copy the code below this line and past in the formula editor, name it and save it under the custom folder ////////////////////////////////////////////////////////

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
mH    =    MA(H, 20);        mL    =    MA(L, 20);

Plot(mH ,"MA-H", IIf(mH > Ref(mH,-1), colorBlue,colorRed), styleThick);
Plot(mL ,"MA-L", IIf(mL > Ref(mL,-1), colorBlue,colorRed), styleThick);

Lx=LastValue(x=BarIndex());
pk=H>Ref(HHV(H,5),-1) AND Ref(HHV(H,5),5)<=H;
tr=L<Ref(LLV(L,5),-1) AND Ref(LLV(L,5),5)>=L;
PlotShapes(shapeSmallCircle*tr, IIf(Lx-ValueWhen(tr,x)>=5,colorBrightGreen,colorWhite),0,round(L*0.999),0);
PlotShapes(shapeSmallCircle*pk, IIf(Lx-ValueWhen(pk,x)>=5,colorOrange,colorWhite),0,round(H*1.001),0);
_SECTION_END();
 ////////////////////////////////////////////////////////
Happy trading !!