price>10sma>50sma>200sma

labdhi

Active Member
#1
plz any seniour person here ,

make a afl for simple condition

buy : price >10sma >50sma>200sma and cover it when price <10sma


sell: price <10sma<50sma<200sma and cover it when price >10sma

plz make this afl explorable and backtestable ...................
 

johnnypareek

Well-Known Member
#2
plz any seniour person here ,

make a afl for simple condition

buy : price >10sma >50sma>200sma and cover it when price <10sma


sell: price <10sma<50sma<200sma and cover it when price >10sma

plz make this afl explorable and back-testable ...................


back-testable
HTML:
_SECTION_BEGIN("Price");
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

EMA10=EMA(C,10);
EMA50=EMA(C,50);
EMA200=EMA(C,200);

Buy=C>EMA10 AND EMA10>EMA50 AND EMA50>EMA200;
Sell=Cross(EMA10,C);
Short=C<EMA10 AND EMA10<EMA50 AND EMA50<EMA200;
Cover=Cross(C,EMA10);
Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);Cover=ExRem(Cover,Short);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
shape1 = Cover * shapeHollowUpArrow + Short * shapeHollowDownArrow;

PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );
PlotShapes( shape1, IIf( Cover, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );