I faced a strange error. I'm using ontime function based EAs and recently some EAs stopped with message "cannot set timer (xxx)". As you know, ontimer function requires 'EventSetTimer(xxx) to run the function repeatively.
Have you guys ever met this kinds of error?
Thank you for your feedback inadvance. :)
No, you are not supposed to run EventSetTimer() repeatedly. You only set it once, for example in the OnInit(), or on the first OnTick(), and never again for the duration of the EA, disabling it in the OnDeinit() cycle.
The only other time you would need to call it again, is if you need to change the timer frequency.
EDIT: If you are using MT4, then also, please read the following thread as it might be related:
I can confirm this is still a mysterious problem even at the latest v4 build 1220.
We run an EA on multi-pairs both VPS hosted and PC. This never happens on the PC, but only on single CPU VPS hosts.
Now, I would like to speculate that the issue may be related to using FTP to push data to myfxbook every 5 seconds. Using a EventSetTimer(10) seem
to be an even number of this.
Perhaps internally MT4 is using similar thread timer for FTP pushes as OnTimer()?
Also @William Roeder mentioned some kind of upper
number of timers per MT4 instance, may be ~60.
Where did you get this from? Also, we only use ~28.
Testing with 30 charts and several timers
I seen that issue using heavy EA in slow PC/VPS.
Usually re-attaching the EA to the graph solve the issue, it can be annoying in case of multiple EA and platform to be run at startup and they need
manual intervention to be re-attached.