Why are the ticks not copied to the custom symbol?

 

I am copying ticks from symbol to Custom symbol. I get holes in history.

This is the script.


//+------------------------------------------------------------------+
//|                                                       script.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
// Creating a copy of the symbol to speed up the tester
#property script_show_inputs

#include <Symbol.mqh> //https://www.mql5.com/ru/code/18855
#include <ErrorDescription.mqh> // https://www.mql5.com/ru/code/79

  int CloneTicks( string SymbFrom = NULL, string SymbTo = NULL, const ulong _from_msc = 0, const ulong _to_msc = LONG_MAX ) 
  {
    int Res;
    SymbFrom = (SymbFrom == NULL) ? _Symbol : SymbFrom;
    if (SymbTo == NULL) return -1;
    if (SymbTo == SymbFrom) return -1;
    if (!::SymbolInfoInteger(SymbTo, SYMBOL_CUSTOM)) return -1;
    MqlTick Ticks[];
    ::CopyTicksRange(SymbFrom, Ticks, COPY_TICKS_ALL, _from_msc, _to_msc);
    Res = ::CustomTicksReplace(SymbTo, _from_msc, _to_msc, Ticks);

    return(Res);
  }
  
void OnStart()
{
  const SYMBOL Symb("TESTER_" + _Symbol); // Created a symbol

  Symb.DeleteHistory();
   Symb.Delete(true);
   Symb.Create(NULL,_Symbol);

  if (Symb.IsExist()) // If a symbol is created
  {
  
    //Symb = _Symbol; // Copied all the properties and bar history (+ tick history if a custom) from the main symbol - clone
   Symb.CloneProperties();
   CustomSymbolSetString(Symb.Name,SYMBOL_PATH,"");
    // Made the currencies of the symbol the currency of the account
    Symb.SetProperty(SYMBOL_CURRENCY_BASE, AccountInfoString(ACCOUNT_CURRENCY));
    Symb.SetProperty(SYMBOL_CURRENCY_PROFIT, AccountInfoString(ACCOUNT_CURRENCY));
    Symb.SetProperty(SYMBOL_CURRENCY_MARGIN, AccountInfoString(ACCOUNT_CURRENCY));
   
    if (Symb.On()) {};// // Included in Market Watch
      //ChartOpen(Symb.Name, PERIOD_CURRENT); // A new symbol chart has been opened

    if (!Symb.CloneRates(_Symbol)) Print("err rates: ",ErrorDescription(GetLastError()));

    datetime date_from=D'2019.01.01';
    datetime dt_start=date_from;
    while (dt_start<TimeCurrent()) {
      Print(dt_start);
      ulong date_start_msc=(ulong)dt_start*1000;
      ulong date_end_msc=(ulong)(dt_start+86400)*1000-1;
       //if (!Symb.CloneHistory(_Symbol,date_start_msc,date_end_msc)) Print("err: ",GetLastError());
       //if (!Symb.CloneTicks(_Symbol,date_start_msc,date_end_msc)) Print("err ticks: ",ErrorDescription(GetLastError()));
       if (!CloneTicks(_Symbol,Symb.Name,date_start_msc,date_end_msc)) Print("err ticks: ",ErrorDescription(GetLastError()));
       MqlTick t1[], t2[];
       int ticks1=CopyTicksRange(_Symbol,t1,COPY_TICKS_INFO,date_start_msc,date_end_msc);
       int ticks2=CopyTicksRange(Symb.Name,t2,COPY_TICKS_INFO,date_start_msc,date_end_msc);
       if (ticks1 != ticks2) {
         Print("wrong ticks count: ",ticks1," / ", ticks2);
         }
       dt_start+=86400;
    }
    
    dt_start=date_from;
    int wrong_bars=0;
    while (dt_start<TimeCurrent()) {
       if (iBarShift(_Symbol,PERIOD_M1,dt_start,true)>=0 && iBarShift(Symb.Name,PERIOD_M1,dt_start,true) < 0) {
         Print("wrong bar: ",dt_start);
          wrong_bars++;
          }
       dt_start+=60;
    }
    Print("total wrong bars: ",wrong_bars);
    //if (Symb.On()) // Included in Market Watch
      ChartOpen(Symb.Name, PERIOD_CURRENT); // A new symbol chart has been opened
  }
  Print("end");
}


This is the output.

...
CS      0       19:01:05.587    script (EURAUD,M1) 2022.09.26 00:00:00
CS      0       19:01:06.049    script (EURAUD,M1) wrong ticks count: 422353 / 0
CS      0       19:01:06.051    script (EURAUD,M1) 2022.09.27 00:00:00
CS      0       19:01:06.519    script (EURAUD,M1) wrong ticks count: 418359 / 0
CS      0       19:01:06.520    script (EURAUD,M1) 2022.09.28 00:00:00
CS      0       19:01:06.962    script (EURAUD,M1) wrong ticks count: 467637 / 0
CS      0       19:01:06.964    script (EURAUD,M1) 2022.09.29 00:00:00
CS      0       19:01:07.348    script (EURAUD,M1) wrong ticks count: 401260 / 0
CS      0       19:01:07.350    script (EURAUD,M1) 2022.09.30 00:00:00
CS      0       19:01:07.725    script (EURAUD,M1) wrong ticks count: 406932 / 0
...
CS      0       19:01:10.011    script (EURAUD,M1) wrong bar: 2022.01.24 11:14:00
CS      0       19:01:10.011    script (EURAUD,M1) wrong bar: 2022.01.24 11:15:00
CS      0       19:01:10.011    script (EURAUD,M1) wrong bar: 2022.01.24 11:16:00
CS      0       19:01:10.105    script (EURAUD,M1) total wrong bars: 2796


Why the CopyTicksRange from custom symbol is 0?

This is the history holes. Why are there a history holes?



.