This is a system taken from ‘BeyondTechnical Analysis’ by Tushar Chande.
“The definition of an extraordinary opportunity as used here is simple. Use a 50-day SMA and plot a 3-percent trading band around it. Then a 7-day SMA must cross outside the upper or lower band to com-plete the identification of extraordinary markets. Thus, if the 7-day SMA. crosses above the upper 3-percent band, an upside extraordinary situation is declared. A converse definition is applicable for bearish markets. The best scenario is that the market follows through vigorously in the direction of the established trend. The worst scenario is that the market teases you for a day or two before returning into a congestion zone. Then use an initial stop to close out the trade.”
I woulld like to put the system in Amibroker AFL. I tried but the Buy & Sell signals were not correct. Please help me to get the buy and sell signals correctly. The AFL I tried is as under,
_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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 50);
Plot( MA( P, 50 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
_SECTION_BEGIN("Percent Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width%", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
CenterLine = MA( P, Periods );
Plot( (1 + Width * 0.01) * CenterLine, "%EnvTop" + _PARAM_VALUES(), Color, Style );
Plot( (1 - Width * 0.01) * CenterLine, "%EnvBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();
_SECTION_BEGIN("MA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 7);
Plot( MA( P, 7 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
_SECTION_BEGIN("MA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 65);
Plot( MA( P, 65 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
Buy =BarsSince(Cross(MA(Close,7),((1 + width * 3)*50))) <=1;
Sell =BarsSince(Cross(MA(Close,7),((1 - Width *3)*50))) <=1;
Please help and test the system afl.