Reding indicator buffer confusion

 

I am just starting with mql5 , However I have plenty of experience in mql4.
but for some reason I am stuck at reading buffer values of a custom indicator in mql5 

this is my code :

 
int handle;
double      cHigh[], cLow[];
datetime    LastActionTime = 0;
int ts_Highs[];
int ts_Lows[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
   {
//---
    EventSetTimer(1);
    handle = iCustom(_Symbol, 0, "tsN");

    return(INIT_SUCCEEDED);
   }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
   {
    EventKillTimer();
   }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTimer()
   {
    string timeC = TimeToString(TimeCurrent(), TIME_MINUTES);
    if(timeC == "23:00" && iTime(_Symbol, _Period, 0) != LastActionTime)
       {
        ArraySetAsSeries(cHigh, true);
        CopyBuffer(handle, 4, 0, 25, cHigh); 
        Print(ArraySize(cHigh)); // This always print 0
        PopulateArrays();
        LastActionTime = iTime(_Symbol, _Period, 0);
       }

   }

/*
----------------------------------------------------------------------
Popuating the arrays for High values
----------------------------------------------------------------------
*/
void PopulateArrays()
   {
    int cnt1 = 0;
    int starting2 = Highest_ts();

    for(int i = starting2; i >= 0; i--)
       {
        if(cHigh[i] != EMPTY_VALUE)
           {
            ArrayResize(ts_Highs, ArraySize(ts_Highs) + 1);
            ts_Highs[cnt1] = i;
            cnt1++;

           }
       }
   }
 
/*
----------------------------------------------------------------------
This function is Identifying the Highest High
----------------------------------------------------------------------
*/
int Highest_ts()
   {
    int         ret         =   99999;
    double      Highest     =   0;

    for(int i = 24; i >= 0; i--)
       {
        if(cHigh[i] >= Highest)
           {
            Highest = cHigh[i];
            ret     = i;
           }
       }
    return ret;
   } 
//+------------------------------------------------------------------+

Can't figure out why the cHigh[] size is always zero.

Indicator buffers:
Image

 
Arad S: Can't figure out why the cHigh[] size is always zero.
  1. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post the indicator or a link to the exact version.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

  2.     handle = iCustom(_Symbol, 0, "tsN");

    Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014)

  3. CopyBuffer(handle, 4, 0, 25, cHigh); 

    Perhaps your indicator doesn't have five (5) buffers.

 
int  CopyBuffer(
   int       indicator_handle,     // indicator handle
   int       buffer_num,           // indicator buffer number
   int       start_pos,            // start position
   int       count,                // amount to copy
   double    buffer[]              // target array to copy
   );

Parameters

indicator_handle

[in]  The indicator handle, returned by the corresponding indicator function.

buffer_num

[in]  The indicator buffer number.

start_pos

[in]  The position of the first element to copy.

count

[in]  Data count to copy.

start_time

[in]  Bar time, corresponding to the first element.

stop_time

[in]  Bar time, corresponding to the last element.

buffer[]

[out]  Array of double type.

Return Value

Returns the copied data count or -1 in case of an error.

Documentation on MQL5: Language Basics / Data Types / Real Types (double, float)
Documentation on MQL5: Language Basics / Data Types / Real Types (double, float)
  • www.mql5.com
Real Types (double, float) - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: