How to set one signal between x candle in future

 

Hi everyone

I have a little problem with some code 

I want : if two ma crossing && if in the next 30 candle in future  there was not any crossing give me a

 alert.

anybody can help me? any idea.

 

I'll share the basic building blocks, but you should post your attempt (code) and then ask for help if you get stuck.

You're going to need two instances (handles) of iMA with the different moving average values you need: https://www.mql5.com/en/docs/indicators/ima

You're going to need to grab the datetime value of the 30th bar that your signal is valid for. You can ascertain this value by getting the current datetime value of the open candle (for the timeframe you're tracking) and then adding it to the value of PeriodSeconds() * 30: https://www.mql5.com/en/docs/common/periodseconds

For the above, I would consider storing the datetime value in a Global Variable so that you know which datetime value it is regardless if you close MT5 / change timeframes / recompile / etc: https://www.mql5.com/en/docs/globals

From there, you should have enough to implement your conditional logic to determine whether the signal is valid.

Documentation on MQL5: Technical Indicators / iMA
Documentation on MQL5: Technical Indicators / iMA
  • www.mql5.com
iMA - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5