Nehal sir one small AFL request.
Logic is
There will be HIGH EMA & LOW EMA
Buy is when price closed above HIGH EMA and only if next candle closed above that.
reverse or Sell is when price closed below LOW EMA and only if next candle closed below that.
can you help me with the AFL for the same?
Toughard
you have not mentioned ema value, used 11 ema in afl, plus not given exit rule, hence exit long when price close below low ema and exit short when price close above high ema
hope this is as per your requirement
_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{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", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("ema_crossover");
x = EMA(Close,11);
y = EMA(High,11);
z = EMA(Low,11);
PH = Ref(High,-1);
PL = Ref(Low,-1);
Plot(EMA(Close,11),"",colorRed,styleLine);
Plot(EMA(Low,11),"",colorPaleGreen,styleLine);
Plot(EMA(High,11),"",colorDarkGreen,styleLine);
Buy= C>O AND C>Y AND C>ph;
Sell=C<Z;
Short= C<O AND C<Z AND C<PL;
Cover=C>Y;
Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
PlotShapes(Buy* shapeUpArrow,colorBlue, 0,L, Offset=-45);
PlotShapes(Short* shapeDownArrow,colorRed, 0,H, Offset=-45);
PlotShapes(Sell*shapeHollowDownArrow,colorPink,0,L,-45);
PlotShapes(Cover*shapeHollowUpArrow,colorSkyblue,0,H,-45);
/////////////////////////////////// Exploration ///////////////////////
Filter = Buy OR Sell;
/////////// General Columns ////////////////////////
AddTextColumn( FullName( ), "Name" );
AddColumn(C,"Close");
AddTextColumn( MarketID( 1 ), "Market name" );
//////////////// BUY/SELL SIGNALS ///////
AddColumn( IIf(Buy,1,IIf(Sell,-1,Null)) ,"Signal1",1.0,colorWhite,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorWhite)));
//////////////////////////////////// Exploration over ////////////////////////////