"Cannot set timer" ???? in ontime function

 

Hello,


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. :)

 
Wonsuk Song: 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?

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:

 
Wonsuk Song: Have you guys ever met this kinds of error?
In an indicator loaded by iCustom.
 
Fernando Carreiro:

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:

Thanks. Funny thing is that other same EA works well, but some of EA stop sometimes. It is running repeatedly. I need to check other opinions. Thank you for your link!
 

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.

 
EAML: Where did you get this from? 

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.

 
EAML:

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.

I used EventSetTimer in EAs a lot but sooner or later would get that same error. I've now given up and use variations of OnTick() for everything time related....
 

Hi,


Last night I had the same error on the simplest of EAs with NO Event Timer.  I just wanted to check out various Indicator parameters over the period of the chart.

It appears the Indicator has a 'NUMBER OF BARS' as an input (not the EA).

It looks like when the number of Bars is exceeded (in the EA) the Indicator 'isn't available' and hence the ERROR.

Different Indicators may calculate all the bars but only display a limit (I guess) and maybe not encounter the error.

 
Fabio Cavalloni #:

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.

If that's because of the slow PC and complex EAs, it makes sense to my case. Thank you for your feedback!