Custom Symbol Not Updating History

 

Good day Community. 
I need help I have this code 

//OnInit  
 CustomSymbolSet();

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CustomSymbolSet()
  {
//---
   m_symbol.Refresh();
   m_symbol.RefreshRates();
//--- enable the Depth of Market for a symbol we are to retrieve data from
   MarketBookAdd(m_symbol.Name());
   CustomSymbolSetInteger(m_customsymbol, SYMBOL_CUSTOM, true);
//---
//--- get the standard symbol tick data to the MqlTick array
   MqlTick array[] = {};
   if(!GetTicksToArray(m_symbol.Name(), UINT_MAX, array))
      return;
//--- print the time of the first and last received ticks of the standard symbol
   int total = (int)array.Size();
   if(!SymbolSelect(m_customsymbol, true))
     {
      Print("SymbolSelect() failed. Error ", GetLastError());
      return;
     }
//--- add the tick array data to the custom symbol price history
   uint start = GetTickCount();
   int added = CustomTicksAdd(m_customsymbol, array);
   printf("added: %d", added);
//--- get the custom symbol tick data to the MqlTick array
   if(!GetTicksToArray(m_customsymbol, array.Size(), array))
      return;
//---
//--- get the number of standard symbol bars
   int bars_origin = Bars(m_customsymbol, PERIOD_M1);
   MqlRates rates[] = {};
   if(CopyRates(m_symbol.Name(), PERIOD_M1, 0, bars_origin, rates) != bars_origin)
     {
      PrintFormat("CopyRates(%s, PERIOD_M1, 0, %d) failed. Error %d", m_symbol.Name(), bars_origin, GetLastError());
      return;
     }
//--- set the copied data to the minute history of the custom symbol
   ResetLastError();
   int updated = CustomRatesUpdate(m_customsymbol, rates);
   int replaced = CustomTicksReplace(m_customsymbol, array[0].time_msc, array[total - 1].time_msc, array);
   PrintFormat("Replaced %u ticks in the history of the custom symbol '%s' in %u ms", replaced, m_customsymbol, GetTickCount() - start);
//---
//---
//--- print the time of the first and last received modified ticks of the custom symbol
   total = (int)array.Size();
   PrintFormat("First changed tick time: %s.%03u, Last changed tick time: %s.%03u",
               TimeToString(array[0].time, TIME_DATE | TIME_MINUTES | TIME_SECONDS), array[0].time_msc % 1000,
               TimeToString(array[total - 1].time, TIME_DATE | TIME_MINUTES | TIME_SECONDS), array[total - 1].time_msc % 1000); //---
//---
//---
   if(updated < 0)
     {
      PrintFormat("CustomRatesUpdate(%s) failed. Error %d", m_customsymbol, GetLastError());
      return;
     }
   int bars_custom = Bars(m_customsymbol, PERIOD_M1);
//--- get and print in the journal the number of custom symbol bars after adding history
   bars_custom = Bars(m_customsymbol, PERIOD_M1);
   PrintFormat("\nAfter CustomRatesUpdate(), the custom symbol '%s' has %d bars of minute history", m_customsymbol, bars_custom);
//--- get the data of all bars of the custom symbol minute timeframe into the MqlRates array
   ResetLastError();
   if(CopyRates(m_customsymbol, PERIOD_M1, 0, bars_custom, rates) != bars_custom)
     {
      PrintFormat("CopyRates(%s, PERIOD_M1, 0, %d) failed. Error %d", m_customsymbol, bars_custom, GetLastError());
      return;
     }
   CustomRatesUpdate(m_customsymbol, rates);
   if(CopyRates(m_customsymbol, PERIOD_M1, 0, bars_custom, rates) != bars_custom)
     {
      PrintFormat("CopyRates(%s, PERIOD_M1, 0, %d) failed. Error %d", m_customsymbol, bars_custom, GetLastError());
      return;
     }
//---
//---Double
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_ASK, m_symbol.Ask());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_BID, m_symbol.Bid());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_ASKHIGH, m_symbol.AskHigh());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_ASKLOW, m_symbol.AskLow());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_BIDHIGH, m_symbol.BidHigh());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_BIDLOW, m_symbol.BidLow());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_MARGIN_HEDGED, m_symbol.MarginHedged());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_VOLUME_STEP, m_symbol.LotsStep());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_VOLUME_MIN, m_symbol.LotsMin());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_VOLUME_MAX, m_symbol.LotsMax());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_VOLUME_LIMIT, m_symbol.LotsLimit());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_MARGIN_INITIAL, m_symbol.MarginInitial());
   CustomSymbolSetDouble(m_customsymbol, SYMBOL_MARGIN_LIMIT, m_symbol.MarginLimit());
//---Integer
   CustomSymbolSetInteger(m_customsymbol, SYMBOL_TRADE_EXEMODE, m_symbol.TradeExecution());
   CustomSymbolSetInteger(m_customsymbol, SYMBOL_TRADE_FREEZE_LEVEL, m_symbol.FreezeLevel());
   CustomSymbolSetInteger(m_customsymbol, SYMBOL_TRADE_STOPS_LEVEL, m_symbol.StopsLevel());
   CustomSymbolSetInteger(m_customsymbol, SYMBOL_TRADE_MODE, m_symbol.TradeMode());
   CustomSymbolSetInteger(m_customsymbol, SYMBOL_TRADE_CALC_MODE, m_symbol.TradeCalcMode());
   CustomSymbolSetInteger(m_customsymbol, SYMBOL_DIGITS, (InpSymbol == GBPUSD ? m_symbol.Digits() - 1 : 0));
   CustomSymbolSetInteger(m_customsymbol, SYMBOL_EXIST, true);
  }

I am having a challenge that my HIstory to my Custom Chart is not being updated. 

So my Custom Symbol digits() is Digits()-1  of the Origil Symbols Digits

Please help what could be making my code not give me history candles. 

 
A custom symbol can't receive ticks automatically, similarly to how you created it manually and added ticks to it, you have to update it manually.