I am trying to implement a simple logic:
1) Find a bar for which MA(C,5) crosses above MA(C,15)
2) From that bar, wait until MA(RSI(),5) crosses above MA(C,15)
3) If 2) happens within 10 bars, then execute a buy otherwise skip
I wrote the following AFL code:
Crossma = Cross(MA(C, 5), MA(C, 15));
Crossrsi = Cross(MA(RSI(), 5), MA(RSI(), 15));
Buy = Crossma AND Crossrsi ;
The problem is that, it seems to me that, Amibroker tests both the conditions on the same bar, where I would like to use the crossover of MA(C) as setup and pull the trigger within the following 10 bars, only if MA(RSI,5) crosses above MA(RSI,15).
Any suggestion on how this could it be done?