Multiple criteria over several bars

Hello

 

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?

 

Thanks
Steve

 

Hi Steve,

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.

eg

Sig1 = {Signal Script 1}; Sig2 = {Signal Script 2};

(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.

See https://help.optuma.com/kb/faq.php?id=1030 for more info on the function.

Hope that helps

Mathew