The key to your timing constraint is BarsSince http://www.amibroker.com/guide/afl/afl_view.php?id=23
The solution for removing redundant signals is ExRem http://www.amibroker.com/guide/afl/afl_view.php?name=exrem I believe that the following will do what you want (assuming condition B as being a simple higher close than the day before): MA1 = MA(Close, 5); MA2 = MA(Close, 25); CrossUp = Cross(MA1, MA2); CrossDn = Cross(MA2, MA1); BarsSinceUp = BarsSince(CrossUp); BarsSinceDn = BarsSince(CrossDn); InRange = BarsSinceUp < BarsSinceDn AND BarsSinceUp < 10; ConditionB = Close > Ref(Close, -1); Candidate = InRange AND ConditionB; Buy = ExRem(Candidate, CrossDn); Plot(MA1, "MA1", colorRed); Plot(MA2, "MA2", colorBlue); Plot(Close, "Price", colorDarkGrey); Plot(BarsSinceUp * InRange, "Range", colorYellow, styleStaircase); PlotShapes(shapeSmallCircle * Candidate, colorOrange, 0, Close, 0); PlotShapes(shapeUpArrow * Buy, colorGreen, 0, Close, -10); Mike --- In [email protected], zeek ing <zeekin...@...> wrote: > > hello all, > > here is an interesting question. one of my triggers is a moving average > crossover. Once the crossover occurs i have another condition. and buy is > created if condition B is met. I want to give the second condition only 10 > bars to be completed after the moving average crossover occurs in order for > the signal to be valid. > > Anyone know how I can set up such a timer? > > Also, once i exit a long i want the timer to expire inorder not to > enter multiple trades after one signal . > > thanks in advance > zeek >
