Plot( C, _DEFAULT_NAME(), IIf( C > Ref(C, -1), colorBlue, IIf(C < Ref(C, -1), colorRed, colorGrey40)), styleBar | styleThick );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(0,chartShowArrows|chartShowDates); //Enable X-Axis (Date/Time Axis)
Plot(EMA(Close,20),"EMA-20",colorGreen , styleLine | styleThick); //Plot Historical Short EMA lines
Plot(EMA(Close,50),"EMA-50",colorBlue , styleLine | styleThick); //Plot Historical Long EMA Lines
//Trading Logic
Buy = Cross(EMA(Close,20),EMA(Close,50)); //Positive EMA Crossover (True/False)
Sell = Cross(EMA(Close,50),EMA(Close,20)); //Negative EMA Crossover (True/False)
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;
TimeFrameSet(inDaily); //move to higher timeframe - 60min
ema13 = EMA(C,13);
ema52 = EMA(C,52);
ema100 =EMA(C,100); //Extract data from higher timeframe
TimeFrameRestore(); //get back to old timeframe
ema13d = TimeFrameExpand(ema13,inDaily); //data expand to match lower timframe dataset
ema52d = TimeFrameExpand(ema52,inDaily);
ema100d = TimeFrameExpand(ema100,inDaily);
Plot(ema13d, "EMA 13",colorRed); //60min timeframe
Plot(ema52d, "EMA 52",colorYellow);
Plot(ema100d, "EMA 100",colorOrange);
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
i have written an afl to explain my problem
Trading logic: buy on 20/50 ema cross over
sell on 20/50 ema cross down
condition : for buy to trigger in 15 min chart (or any time frame) daily ema13>ema52>ema100
for sell to trigger in 15 min chart daily ema100>ema52>ema13
values used here have no trading significance i am using random numbers to learn.
Please help me how can i remove incorrect sell signals from below chart( i know i can write an exploration, filter stocks add them to a watch-list and apply my system on the watch-list, i am looking for a better solution)