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.

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.