Hi , i have this code i want to test a brokers stop levels .
When i comment out the sections defined on the timer function the timer can be set .
When i leave it as is i get an error "Cannot set millisecond timer (100)"
It's probably something i missed , but i can't find it.
Also , an mt5 is running an optimization while this happens , i currently can't stop the optimization to see if the timer can be set however.
Someone run this on their machine , that was not running an optimization on mt5 and they dont get the error.
It has to do with the cores being used or something , i guess
When setting the timer, you have to retry several times, as it sometimes fails on the first few calls.
William has posted about this several times. Do a search of his posts about it.
Forum on trading, automated trading systems and testing trading strategies
William Roeder, 2020.02.24 17:50
-
You have to on MT4, because sometime it returns an error (4030.)
EST can fail. The default suggestion is to loop until you enable it.
Build 1080 Cannot Set Timer error with EventSetTimer function - Indices - MQL4 programming forum #8I don't try to enable them in OnInit but instead I keep trying to enable them in OnTick/OnCalculate until they succeed. (No race condition, no CPU loop, no timer ticks before chart is updated.)
Cannot set timer (60) - EA not working - MT4 - MQL4 programming forumint OnInit(){ while(!EventSetTimer(1) ){ alert_id(StringFormat("EST:%i", _LastError) ); Sleep(5000); if(_StopFlag) return INIT_FAILED; }
1 09:31:41.071 order_graphic_tool_v6 USDCHF,Daily: cannot set timer (1)
0 09:31:41.071 order_graphic_tool_v6 USDCHF,Daily: Alert: order_graphic_tool_v6 USDCHF D1 EST:4030
0 09:31:41.071 order_graphic_tool_v6 NZDCAD,Daily: Alert: order_graphic_tool_v6 NZDCAD D1 EST:4030
1 09:31:41.071 order_graphic_tool_v6 GBPCHF,Daily: cannot set timer (1)
1 09:31:41.071 order_graphic_tool_v6 AUDSGD,Daily: cannot set timer (1)
0 09:31:41.071 order_graphic_tool_v6 GBPCHF,Daily: Alert: order_graphic_tool_v6 GBPCHF D1 EST:4030
0 09:31:41.071 order_graphic_tool_v6 AUDSGD,Daily: Alert: order_graphic_tool_v6 AUDSGD D1 EST:4030
1 09:31:41.071 order_graphic_tool_v6 USDCAD,Daily: cannot set timer (1)
1 09:31:41.071 order_graphic_tool_v6 GBPJPY,Daily: cannot set timer (1)
0 09:31:41.071 order_graphic_tool_v6 GBPJPY,Daily: Alert: order_graphic_tool_v6 GBPJPY D1 EST:4030
0 09:31:41.071 order_graphic_tool_v6 USDCAD,Daily: Alert: order_graphic_tool_v6 USDCAD D1 EST:4030
In EA I'm using 5 second sleep, which usually doesn't result in a second attempt. For indicators try and set it in OnCalculate. On failure return zero and retry next tick. This drastically reduces the problem.
Thank you
EST:4024 , both on init and on tick
All cores are busy , probably related
I'm not good at CS at all , but the machine has not restarted for 30hrs more or less and it was optimizing both on excel's genetic algo and mt5 for about a day straight.
I wonder if the MQL4 error codes have changed?
According to the documentation ... Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL4 Reference
4024
ERR_INTERNAL_ERROR
Internal error
4030
ERR_CHART_NOREPLY
No reply from chart
- docs.mql4.com
I wonder if the MQL4 error codes have changed?
According to the documentation ... Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL4 Reference
4024
ERR_INTERNAL_ERROR
Internal error
4030
ERR_CHART_NOREPLY
No reply from chart
What's internal error ?and why it can set the timer when i comment out a section on the timer function ?
I guess having 2 machines would be betterWhen you comment out the OnTimer function, it probably ignores the EST.
I mean a section inside the function not the on timer function , where the comments are
By the way, this is an EA and not an indicator or script, correct?
EA , and i'm currently on a 2nd generation i3 , nothing powerful .
Can i shut off use of 1 core in the mt5 tester (while its running preferablly)?
Yes, I deleted my post after I saw that you were not commenting out the entire function but just part of it.
Never tried it, so don't know.
Try not to kill the timer here:
void OnTimer(){ EventKillTimer();
To make the code inside the OnTimer() be executed only once, you can use the flag.
Perhaps the timer just took offense at you for killing him. He will still write "timer" in his journal, but he does not want to trade for you after you treated him ugly.
This is just another joke of mine, but I think you should check it out.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi , i have this code i want to test a brokers stop levels .
When i comment out the sections defined on the timer function the timer can be set .
When i leave it as is i get an error "Cannot set millisecond timer (100)"
It's probably something i missed , but i can't find it.
Also , an mt5 is running an optimization while this happens , i currently can't stop the optimization to see if the timer can be set however.