Download MetaTrader 5

EventSetTimer() Question

To add comments, please log in or register
Hai Nguyen
116
Hai Nguyen  

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  

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  
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
15013
whroeder1  
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  
put in OnTick()
To add comments, please log in or register