I've tried searching for this answer, but so far I haven't found it...
How do I determine if an event happened within the last xx bars. For example, say I have a MA that crosses over some signal line. In general, how do I determine if that cross happened within the last 10 bars. Something like the below (yes, it's not real code, just pseudo code.)
How do I determine if an event happened within the last xx bars. For example, say I have a MA that crosses over some signal line. In general, how do I determine if that cross happened within the last 10 bars. Something like the below (yes, it's not real code, just pseudo code.)
Code:
def trigger = ma crosses signal within 1 to 10 bars ago