Yep, the server time is updated on a tick, you can get it using TimeCurrent()
I've not used OnTimer() yet, but from the documentation it seems that you set the time using EventSetTimer() called from OnInit()
Ok so i am more or less done with my the mt4 part of my code. This eventsettimer, does it turn off the EA and start it again every 'x' seconds as specified or just takes away the execution rights from the EA for that while.
Is there any way i could execute another operation in between this time? say an important piece of data arrives in between this 'x' interval of time can i somehow operate on this data or do i have to wait till the 'x' seconds have passed away?
Oh sorry my bad. using void Ontick would work solve the issue.
And is there any way to sync this eventsettimer with 00:00:00 hours? 00:00:30 next would be 00:01:00 next 00:01:30.....and so on. i was thinking of getting current time in seconds, then dividing it by 30 and use the greatest integer function. only when my current time is an integer multiple of it will the code give the signal for next 30 seconds. any other ideas?
You can detect when Midnight has occurred since the last tick . . . if there is no tick from 5 seconds to Midnight till 5 seconds after you will miss the actual Midnight second. Alternatively just set the EventSetTimer() called from OnInit() to the number of seconds left before the start of the next minute or half minute and then in the first OnTimer() call reset the timer to 30 seconds.
To set the first timer . . .
int FirstOnTimerPeriod = 0;
static bool SetFirstTimerPeriod = false;
FirstOnTimerPeriod = MathMin( TimeCurrent()%60, TimeCurrent()%30 );
SetFirstTimerPeriod = true;
Then in OnTimer()
static boolsSetTimerTo30Secs = false;
EventSetTimer(30); // reset to 30 seconds on first call