How to check if price crossed an indicator at any time during the last "N" candles
-
I need help building a way to enter into a trade but only if price crosses an indicator within "N" candles of price crossing a different indicator. for example: enter a short trade anytime price crosses below the 50 ema but only if price crossed below the 20 ema anytime in the last 20 candles. Any help would be greatly appreciated
-
You can use variables to tell the launcher when that happened. You can also create a loop, but the first option is easier. Are you familiar with variables?
-
I've used variables for some ea's i've made before but I'm not quite sure how I'd do it in this case. could you create an example of how this would work. thank you
-
@jpj52byu You can do something like this:

I used 2 different MA to confirm there was a crossing somewhere in the last 50 candles. However, this way to do it will not tell you if there was more then one crossing with that period.