Q: Bug in mql5 - OnTick() before OnInit()

 

Hi,

I think I found a bug in MQL5.

My EA starts with the code shown below. During testing with the debugger I had set 4 breakpoints (indicated with '>' in de code below.

As it turned out, at one of my test-sessions the first breakpoint that the program stopped at was in the OnTick() function. I would expect that an EA would always execute OnInit() before OnTick() or OnTimer(). Did I find a bug or is there a reason for the observed behaviour?

int OnInit() {
>  ObjectsDeleteAll();  // Clean charts
   EventSetTimer(60);   // Set timer event to 60 seconds
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason) {
>  ObjectsDeleteAll();  // Clean charts
   EventKillTimer();    // Destroy timer event      
}

void OnTick()   {
>  do_open(MagicNumber);   
}

void OnTimer() {
>  do_manage(MagicNumber);
}