How do I check if two criteria are met over x number of bars?
For example, I would like to see if I get a MA crossover near (say within 3 bars) when another MA turns down? I can get a result if both events occur on the same bar, but how do I see those instances where both events happen within 3 bars?
You can use the “TimeSinceSignal()” function to get how many bars since the event occurred. So with this we just need to make sure that each TimeSince is less than 4 bars.
(TimeSinceSignal(Sig1) < 4) AND (TimeSinceSignal(Sig2) < 4)
This will only trigger if they are both within 3 days of each other. Note that you may get multiple results. If that is the case you can use a NoRepeat() function to limit it to 1.