Check for elapsed time?
- OnCalculate. The function is called in the indicators when the Calculate event occurs for processing price data changes.

Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
- www.mql5.com
Trade Server Return Codes - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
//global datetime wait; if (TimeCurrent() < wait) return; //check initially and every 20 seconds wait=TimeCurrent()+20;
Is there a reason not to be doing this task with the OnTimer() event function with EventSetTimer(20) set in OnInit()?

You are missing trading opportunities:
- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would like to repeat a task every 20 seconds is that how to do it?