Hi guys. I wanted to test the timer (OnTimer) and I did a very simple script.
int tempo;
int OnInit()
{
EventSetMillisecondTimer(1);
Print("0: GetTickCount: " + GetTickCount() + " GetMicrosecondCount: " + GetMicrosecondCount());
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
EventKillTimer();
}
void OnTimer()
{
tempo++;
if(tempo == 1) Print("1: GetTickCount: " + GetTickCount() + " GetMicrosecondCount: " + GetMicrosecondCount());
if(tempo == 10) Print("10: GetTickCount: " + GetTickCount() + " GetMicrosecondCount: " + GetMicrosecondCount());
if(tempo == 100) Print("100: GetTickCount: " + GetTickCount() + " GetMicrosecondCount: " + GetMicrosecondCount());
if(tempo == 1000) Print("1000: GetTickCount: " + GetTickCount() + " GetMicrosecondCount: " + GetMicrosecondCount())
}
But I get a strange result. As you can see from the MT4 log a lot more than 1, 10, 100 and 1000 ms have passed.
2019.04.11 22:37:15.819 TestTimer EURUSDq,H1: 1000: GetTickCount: 10043531 GetMicrosecondCount: 15614678
2019.04.11 22:37:01.757 TestTimer EURUSDq,H1: 100: GetTickCount: 10029468 GetMicrosecondCount: 1552525
2019.04.11 22:37:00.358 TestTimer EURUSDq,H1: 10: GetTickCount: 10028062 GetMicrosecondCount: 153794
2019.04.11 22:37:00.211 TestTimer EURUSDq,H1: 1: GetTickCount: 10027921 GetMicrosecondCount: 6875
2019.04.11 22:37:00.204 TestTimer EURUSDq,H1: initialized
2019.04.11 22:37:00.204 TestTimer EURUSDq,H1: 0: GetTickCount: 10027906 GetMicrosecondCount: 274
2019.04.11 22:37:00.191 Expert TestTimer EURUSDq,H1: loaded successfully
I have tried on 4 different versions of MT4 and I always get the same result.
Am I doing something wrong??
Thank for Help