-
Why did you post your MT4 question in the
Root /
MT5 EA section
instead of the MQL4 section,
(bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - I also get intermittent errors creating timers.
- There is a maximum number of timers, (somewhere above 60.)
- Various error codes (including 4024 and 4030.) So I don't enable them in OnInit but instead I keep trying to enable them in OnTick/OnCalculate until they succeed.
- I use a globally declared singleton of:
class Ticker{ // EventSetTimer sometimes fails in OnInit, on MT4, with internal error. So // remember to try it in OnCalculate public: Ticker(void) : mTickerStatus(false){} //[CTor] public: // Methods bool enable(void){ if(mTickerStatus != TS_ACTIVE){ if(!EventSetTimer(1) ){ alert_id(StringFormat("EST:%i", _LastError) ); mTickerStatus = TS_ERROR; return false; } if(mTickerStatus == TS_ERROR) alert_id("EST: Successful"); mTickerStatus = TS_ACTIVE; } return true; } void disable(void){ EventKillTimer(); mTickerStatus = false; } private: // Data enum TckStatus{ TS_IDLE, TS_ERROR, TS_ACTIVE }; TckStatus mTickerStatus; }; // class Ticker
- There is a maximum number of timers, (somewhere above 60.)
whroeder1:
Can you explain more.
-
Why did you post your MT4 question in the
Root /
MT5 EA section
instead of the MQL4 section,
(bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - I get errors creating timers also.
What is unclear?
Chathusanka Yamasinghe:
This is the error I got when I running the EA. But some mt4 apps runs the EA perfect. But Exness broker mt4 gives this error to me.
Anyone can help me to fix this.
Trying to add this code onInit()
int count=0; bool timerset=false; while(!timerset && count<5) { timerset=EventSetTimer(60); if(!timerset) { printf("Cannot set timer, error %s. Set trying %d...",(string)_LastError,count); EventKillTimer(); Sleep(200); timerset=EventSetTimer(60); count++; } } if(!timerset) { Alert("Cannot set timer"); return INIT_FAILED; } else { printf("%s success on setting timer.",Symbol()); }
Nguyen Quan Thanh:
Please insert the code correctly: when editing a message, press the button Trying to add this code onInit()


You are missing trading opportunities:
- Free trading apps
- 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
This is the error I got when I running the EA. But some mt4 apps runs the EA perfect. But Exness broker mt4 gives this error to me.
Anyone can help me to fix this.