Amibroker AFL how to ignore repainting signals

Below is my code:

st = SuperTrend(10,3);

_x = TimeFrameGetPrice(“H”, inDaily, -1);
_y = (_x * 1.009);
_z = TimeFrameGetPrice(“H”, inDaily );

cond1 = Cross(C, st);

cond2 = _z > _y;

Buy = cond1 AND cond2;
Sell = Cross(st, C) ;

Plot(_y, “P_DaysH”, colorGold,styleDashed,0,0,0,0,0);
Plot(_z, “DaysH”, colorOrange,styleDashed,0,0,0,0,0);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone), colorGreen, 0,L, offset=-120);

Problem I am facing is if cond2 gets satisfied in future, signal gets generated on previous signal candle (at right place) can anyone guide on how to ignore that. I want signal should be generated only if its a latest candle and both conds are true. In the attached file you can see that cond2 turns true after 3 candles from cond1 and buy signal turns true at the place of cond1 == true.

1 Like