AFL For Karthik's EOD strategy required

#1
hi ,
Karthik has explained his EOD strategy,it would be helpfull if someone can code it to afl,the conditions are

Setup
Time Frame : Daily
chart: EMA 3 & EMA 10 on close price
ADX : 14

Entry Rule:

Buy : 3EMA cross 10EMA from below
ADX: +DI > -DI
SL : Low of the trade trigerred candle

Sell : 3EMA cross 10EMA from above
ADX: -DI > +DI
SL : High of the trade trigerred candle

Exit : When the price not touching 3EMA (or) some fixed % depending upon the risk taking appetite.

Important: There will be no trade if the condition of EMA & ADX both are not met

Thank You
 
#3
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", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
 
 
_SECTION_BEGIN("ADX Trend Ribbon"); 
ADXcolor = IIf(PDI() > MDI(),colorBlue,colorRed);
Plot(10, "", ADXcolor, styleArea | styleNoLabel | styleOwnScale,0,300);
_SECTION_END();
 
 
_SECTION_BEGIN("System"); 

e10 = EMA(C,10);  
e3  = EMA(C,3); 

Plot(e3, "e3", colorLime, styleDashed | styleThick); 
Plot(e10, "e10", colorBlueGrey, styleThick); 
 
Buy  = ADXcolor == colorBlue AND e3 > e10; 
Sell = ADXcolor == colorRed  AND e3 < e10; 
 
Buy  = ExRem(Buy,Sell); 
Sell = ExRem(Sell,Buy); 
   
PlotShapes(Buy * shapeUpArrow, colorBlueGrey, 0, L,-30); 
PlotShapes(Sell * shapeDownArrow, colorLime, 0, H,-30); 

_SECTION_END();

_SECTION_BEGIN("Stops"); 
SL[0]=O[0];
for (i = 1;i < BarCount;i++)
{
	if 	(Buy[i])       SL[i] = L[i];
	else if (Sell[i]) SL[i] = H[i];
	else              SL[i] = SL[i-1];
}
Plot(SL, "SL", colorDarkGrey, styleDashed | styleStaircase); 

_SECTION_END();
 
Last edited:

sanjn84

Active Member
#4
can it is possible that backtest can be done by using this afl .
thanks ptt for nice effort.
 

Similar threads