need afl for strategy

Gandhar.

Well-Known Member
#1
strategy ----


buy on crossover of 9/30 ema
sell on continuous 3 candles close below 30ema

short on crossover of 30/9 ema
cover on continuous 3 candles above below 30ema

please make this afl backtestable


thanks :D:thanx:
 
#2
Code:
_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", colorDefault, styleNoTitle | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods1 = Param("Periods1", 9, 1, 500, 1, 10 );
Periods2 = Param("Periods2", 30, 1, 500, 1, 10 );
Plot(e9 = EMA( P, Periods1 ), StrFormat(_SECTION_NAME()+"(%g)", Periods1), ParamColor( "Color1", colorRed ), ParamStyle("Style") ); 
Plot(e30 = EMA( P, Periods2 ), StrFormat(_SECTION_NAME()+"(%g)", Periods2), ParamColor( "Color2", colorBlue ), ParamStyle("Style") ); 
Buy 	=	Cross(e9, e30); 
Sell	=	C < e30 AND Ref(C,-1) < Ref(e30,-1)  AND Ref(C,-2) < Ref(e30,-2); 
Buy 	=	ExRem(Buy,Sell);		Sell	=	ExRem(Sell,Buy);
Short	=	e9  < e30;
Cover	=	C > e30 AND Ref(C,-1) > Ref(e30,-1)  AND Ref(C,-2) > Ref(e30,-2); 
Short 	=	ExRem(Short,Cover);	Cover	=	ExRem(Cover,Short);
PlotShapes(Buy+2*Short, colorWhite, 0,IIf(Buy,L,H));	
PlotShapes(3*Cover+4*Sell, colorWhite, 0,IIf(Cover,L,H),-24);	
Color1 = IIf( EMA(p,periods1) > EMA(p,periods2), colorGreen, colorYellow);
Plot(1, "", Color1, styleArea | styleOwnScale | styleNoLabel, -0.1, 30 );
_SECTION_END();
 
#4
@HAPPY SINGH
SIR I HAVE A STRATEGY AND ITS A BIT COMPLEXED IN TERMS OF PROGRAMING.
I HAVE DESIGNED A FLOW CHART FOR THAT BASED ON MY VIEW.
I HAVE CHECKED IT WITH PAST DATA. WORKS ON BOTH INTRADAY AND SHORT TERM LONG TERM. ITS BASED ON HIGHER TOPS AND LOWER BOTTOM CANDLES CHANGING TREND.

PLEASE CAN YOU MAIL ME YOUR CONTACT DETAILS. I WANT TO EXLPLAIN YOU EVERYTHING IN DETAIL SO THAT YOU CAN HELP ME OUT.

REPLY ME AS EARLY AS POSSIBLE ON
[email protected]
 

Similar threads