Confusion about iClose and CopyRates data syncronization

 
So I have been reading through https://www.mql5.com/en/forum/451498 and https://www.mql5.com/ru/forum/442814/page2 and from what I understand the iClose/iOpen and things like CopyTime can return wrong values if not synced up and is therefore unreliable? But with both don't you still just check and make sure the buffer is filled like how you do it with indicators with the <= 1 right? 
double close_price = iClose(_Symbol, PERIOD_CURRENT, 1);  

   if (close_price == 0){
      Print("Warning: iClose returned 0");  
      // Obviously add some retry mechanism here 
   }

Also does iTime have this issue as well? If it does I'm going to start questioning my entire existence. 


P.S. it seems you can do stuff with SeriesInfoInteger and SERIES_SYNCHRONIZED but still that feels like a lot of extra work just to use in built functions. So if I have already built my EA with these functions should I just add this into the beginning of my OnTick function that make sure everything is synced up? 

void OnTick(){
   long is_synced = 0;
   if (!SeriesInfoInteger(_Symbol, PERIOD_CURRENT, SERIES_SYNCHRONIZED, is_synced) || is_synced != 1){
      Print("Time series not synchronized for ", _Symbol);
      // add retry mechanism when not lazy lmao
   }  
}

Or should I just start using CopyRates instead? Since I use multisymbol EAs the above code would obviously be different but I'm still confused as to why the iClose/Open/Time functions need the synchronization and CopyRates does not. Pls someone with more experience give advice on what you personally do/think is better, would greatly appreciate it. 

Differance between MqlRates and other methods ?
Differance between MqlRates and other methods ?
  • 2023.07.27
  • Ahmed_Fouda
  • www.mql5.com
is there any difference between using MqlRates and using iCLose for example...
 

You may just check error codes to make sure they are returning correct values:

History Access

 

 

ERR_HISTORY_NOT_FOUND

4401

Requested history not found

ERR_HISTORY_WRONG_PROPERTY

4402

Wrong ID of the history property

ERR_HISTORY_TIMEOUT

4403

Exceeded history request timeout

ERR_HISTORY_BARS_LIMIT

4404

Number of requested bars limited by terminal settings

ERR_HISTORY_LOAD_ERRORS

4405

Multiple errors when loading history

ERR_HISTORY_SMALL_BUFFER

4407

Receiving array is too small to store all requested data