Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Libraries | Timer

MetaTrader Experts, Indicators, Scripts and Libraries

Callback interface for timer

You can also use the npm package manager to download
npm i mql5-timer
example:
#include "../index.mqh";    ulong intervalId; // id for cancel    void OnInit(void) {      Timer::setTimeout(Callback1, 3000, "321"); // after 3000ms      Timer::setTimeout(Callback2, 2000); // after 2000ms        intervalId = Timer::setInterval(myCallback3, 800, "myCallback4 800"); // every 800ms        // any type of param      TypedTimer<int>::setTimeout(Callback4, 1000, 123); // after 1000ms      TypedTimer<string>::setInterval(myCallback5, 1800, "myCallback4 1800"); // every 800ms  }    void Callback1(string value) {      Print("Called with value: ", value);  }  void Callback2() {      Print("Called with value: ", "void");  }  void myCallback3(string param) {      Print(param);      Timer::clearInterval(intervalId);  }    void Callback4(int value) {      Print("Called with value: ", value);  }  void myCallback5(string param, ulong idForCancel) {      Print(param);      Timer::clearInterval(idForCancel);  }
authtor: Kuzme Shevelev (seffele@gmail.com)
github:  https://github.com/Senails/mql5-timer
53101