I am trying to draw simple Buy and Sell arrows in the chart using cross function. However, it is not drawing anything on chart where the two lines are EMA() and Accdist() are crossing. Not sure what is wrong with the code, can anyone help?
_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();
Periods = Param("PeriodsEMA", 50, 2, 300, 1, 10 );
Plot( EMA( V, Periods ), "EMA", colorRed, styleOwnScale|styleThick );
Plot( AccDist(), "AccDist", colorBlue, styleOwnScale|styleThick );
Sell=Cross( EMA(V,Periods), AccDist()) ;
Buy=Cross(AccDist(),EMA(V,Periods)) ;
Short=Sell;
Cover=Buy;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
_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();
Periods = Param("PeriodsEMA", 50, 2, 300, 1, 10 );
Plot( EMA( V, Periods ), "EMA", colorRed, styleOwnScale|styleThick );
Plot( AccDist(), "AccDist", colorBlue, styleOwnScale|styleThick );
Sell=Cross( EMA(V,Periods), AccDist()) ;
Buy=Cross(AccDist(),EMA(V,Periods)) ;
Short=Sell;
Cover=Buy;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );