Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 can create custom graphical tools?
Hai Nguyen
116
Hai Nguyen 2014.02.25 02:06 

Hello everyone,

I am trying to understand how the EventSetTimer() works. Hopefully, some one could address it for me.

If I attached the EA at 12:40PM and set EventSetTimer(900) (which is 15 minutes), would it mean the OnTimer() will run at 12:55PM, 1:10PM, 1:25PM ...?

How do you code to set the OnTimer() to run every 4-hour at a round hour like 4:00, 8:00,...(does not matter what time EA is attached)?

Thank you for helping out.

Regards,

PS: please don't judge my question, I'm new to the language.

qjol
3243
qjol 2014.02.25 02:21  

aquarchitecture:

If I attached the EA at 12:40PM and set EventSetTimer(900) (which is 15 minutes), would it mean the OnTimer() will run at 12:55PM, 1:10PM, 1:25PM ...?

Correct

aquarchitecture:

How do you code to set the OnTimer() to run every 4-hour at a round hour like 4:00, 8:00,...(does not matter what time EA is attached)?


if (your condition)
EventSetTimer(in seconds);
Hai Nguyen
116
Hai Nguyen 2014.02.25 02:38  
qjol:
Correct

Thank qjol for getting back to me.

Where should I put that code? I am pretty sure NOT in OnInit(). Can you write an example code for me?

whroeder1
13640
whroeder1 2014.02.25 02:41  
aquarchitecture: If I attached the EA at 12:40PM and set EventSetTimer(900) (which is 15 minutes), would it mean the OnTimer() will run at 12:55PM, 1:10PM, 1:25PM ...?<
EventSetTimer says "determine the frequency of the timer event" No where does it say WHEN the trigger occurs. I assume 12:40+900=12:55 etc. but it could just as well mean iTime(, PERIOD_M1,0) > time of[ EventSetTimee(x) ] + x. Don't assume.
qjol
3243
qjol 2014.02.25 03:00  
put in OnTick()
/
To add comments, please log in or register