not able to return the value through indicator.

 

Here is the indicator which is returning the time remaining for the new bar:

//+------------------------------------------------------------------+
//|                                              CandleTimeStationary|
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property strict
#property indicator_buffers 1
//---- input parameters
input color Clock_Color = clrWhite;
input ENUM_BASE_CORNER Corner = CORNER_LEFT_LOWER;

string objname="Spread&Bar";
double s1[];
double remainingtime[];
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer(0,remainingtime,INDICATOR_CALCULATIONS);
        ObjectCreate(0, objname, OBJ_LABEL,0, 0, 0);
        ObjectSetInteger(0, objname, OBJPROP_CORNER, Corner);
        ObjectSetInteger(0, objname, OBJPROP_XDISTANCE, 10);
        ObjectSetInteger(0, objname, OBJPROP_YDISTANCE, 2);
        ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER;
        switch (Corner)
        {
                case CORNER_LEFT_UPPER: Anchor=ANCHOR_LEFT_UPPER; break;
                case CORNER_RIGHT_UPPER: Anchor=ANCHOR_RIGHT_UPPER; break;
                case CORNER_LEFT_LOWER: Anchor=ANCHOR_LEFT_LOWER; break;
                case CORNER_RIGHT_LOWER: Anchor=ANCHOR_RIGHT_LOWER; break;
        }
        ObjectSetInteger(0, objname, OBJPROP_ANCHOR, Anchor);
        
        return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason) { ObjectDelete(0, objname); } 

//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spreads[])
{
        ArraySetAsSeries(time, true);
        int m=int(time[0]+PeriodSeconds()-TimeCurrent());
        int s=m%60;
        m=(m-s)/60;
        long spread=SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
        
        string _sp="",_m="",_s="";
        if (spread<10) _sp="..";
        else if (spread<100) _sp=".";
        if (m<10) _m="0";
        if (s<10) _s="0";
        
        ObjectSetString(0, objname, OBJPROP_TEXT, "Spread: " +IntegerToString(spread)+_sp+" Next Bar in "+_m+IntegerToString(m)+":"+_s+IntegerToString(s));
        remainingtime[0] = s;
        Print(remainingtime[0]);
        ObjectSetInteger(0, objname, OBJPROP_FONTSIZE, 10);
        ObjectSetInteger(0, objname, OBJPROP_COLOR, Clock_Color);
        ObjectSetString(0, objname, OBJPROP_FONT, "Courier");
        
        return(rates_total);
}

I am getting the correct value on printing. But when I am calling it through the expert then I am getting only zeroes.

Here is the expert:  

//+------------------------------------------------------------------+
//|                                          mystrategyIQOptions.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+

int candletime;
double remaining_time[];


int OnInit()
  {
//---
   candletime = iCustom(_Symbol,_Period,"candle_time_end_and_spread.ex5");
   
   ArraySetAsSeries(remaining_time,true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
   IndicatorRelease(candletime);
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
////---
     CopyBuffer(candletime,0,0,1,remaining_time);
   ArrayPrint(remaining_time);
  }
//+------------------------------------------------------------------+

Please let me know what I am doing wrong.

Reason: