CopyTicksRange does not take ticks

 

Hello everyone,


I'm trying to use the CopyTicksRange function and it does not copy any ticks. I'm connected to the FTMO server and I'm able to download the ticks through the symbols menu and also, I'm able to get rates using CopyRates. Here is an example:

void OnInit() {
   MqlTick ticks[];
   int count = CopyTicksRange(
      _Symbol, 
      ticks,
      COPY_TICKS_ALL,
      D'2025.05.19 00:00',
      D'2025.05.23 23:59'
   );
   
   Print("Number of ticks: ", count);
   
   MqlRates rates[];
   count = CopyRates(
      _Symbol,
      PERIOD_M1,
      D'2025.05.19 00:00',
      D'2025.05.23 23:59',
      rates
   );
   
   Print("Number of rates: ", count);
}

This shows the following:


As it can be seen the number of ticks is 0.


I've even tried to select the history using:

HistorySelect(D'2025.05.19 00:00', D'2025.05.23 23:59');

No luck with these approaches. Anyone has any idea? Am I missing something? Is this a bug?


Many thanks,

Kevin

 
Kevin de la Coba Malam:

Hello everyone,


I'm trying to use the CopyTicksRange function and it does not copy any ticks. I'm connected to the FTMO server and I'm able to download the ticks through the symbols menu and also, I'm able to get rates using CopyRates. Here is an example:

This shows the following:


As it can be seen the number of ticks is 0.


I've even tried to select the history using:

No luck with these approaches. Anyone has any idea? Am I missing something? Is this a bug?


Many thanks,

Kevin

Try this algorithm

Free download of the 'Download all ticks of a symbol's history' expert by 'LoRio' for MetaTrader 5 in the MQL5 Code Base, 2025.02.22
Download all ticks of a symbol's history
Download all ticks of a symbol's history
  • www.mql5.com
Download all the ticks from your broker for all the symbols in the market watch. Download all history or until a specific date in the past if available.
 
Found the issue. We don't have to send a datetime object, we have to send the miliseconds.
   int count = CopyTicksRange(
      _Symbol, 
      ticks,
      COPY_TICKS_ALL,
      1747959921000,
      1748039121000
   );
 
Kevin de la Coba Malam:

I'm trying to use the CopyTicksRange function and it does not copy any ticks. I'm connected to the FTMO server and I'm able to download the ticks through the symbols menu and also, I'm able to get rates using CopyRates. Here is an example:

This shows the following:


As it can be seen the number of ticks is 0.


I've even tried to select the history using:

No luck with these approaches. Anyone has any idea? Am I missing something? Is this a bug?

Do not call CopyTicksRange in OnInit.

You did not specify what type of the program you're writing - this is important, because in indicators CopyTicksRange works asynchronously - if tick history is not yet available, the call will return 0 immediately and start ticks history synchronization, so your program needs to repeat request after a while.

 
An that's why MQL5 programming is weak because it is not an Event Driven language, so you have to do stupid polling functions in order to check what is going on...
 
Flavio Javier Jarabeck #An that's why MQL5 programming is weak because it is not an Event Driven language, so you have to do stupid polling functions in order to check what is going on...

I understand the frustration that can come with certain aspects of working in MQL5, especially when one expects a more event-driven behavior. However, your comment feels more like a personal vent than a concrete contribution to the issue being discussed.

Saying that MQL5 is "weak" because it’s not event-controlled isn't entirely accurate. The language provides tools like OnTimer that are specifically designed to handle asynchronous scenarios, such as waiting for tick history to synchronize.

This kind of periodic check is both valid and commonly used, nothing overly complex.

It's less about a limitation of the language and more about understanding and applying the available tools effectively. Sharing that kind of practical solution would be much more helpful to others facing similar problems.