I'm trying to create AFL for this strategy. I wrote one but not very sure if its the correct representation of the system. Can some one please verify. I'm planning to back test this strategy in ami.
Code:
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | styleBar);
_SECTION_BEGIN("MA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 5, 2, 80, 1 );
MA1 = EMA( P, Periods);
Plot( MA1, _DEFAULT_NAME(), ParamColor( "Color", colorRed ), styleThick );
_SECTION_END();
_SECTION_BEGIN("MA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 13, 2, 90, 1 );
MA2 = EMA( P, Periods );
Plot( MA2, _DEFAULT_NAME(), ParamColor( "Color", colorYellow ), styleThick );
_SECTION_END();
stkFast = StochD(8,3,1);
stkSlow = StochD(8,3,4);
TimeFrameSet(30*in1Minute);
F30 = StochD(8,3,1);
S30 = StochD(8,3,4);
TimeFrameRestore();
F30 = TimeFrameExpand(F30, in1Minute * 30);
S30 = TimeFrameExpand(S30, in1Minute * 30);
Buy = Cross(MA1,MA2) AND stkFast > stkSlow AND stkSlow < 80 AND F30 > S30;
Sell = Cross(80,stkFast) ;
Short = Cross(MA2,MA1) AND stkFast < stkSlow AND stkSlow > 20 AND F30 < S30;
Cover = Cross(stkFast,20) ;
PlotShapes( shapeUpArrow*Buy, colorGreen, 0, L, -20 );
PlotShapes( shapeDownArrow*Sell, colorBlue, 0, H, -30 );
PlotShapes( shapeDownArrow*Short, colorRed, 0, H, -20 );
PlotShapes( shapeUpArrow*Cover, colorYellow, 0, L, -30);