I'm having an issue with the ArraySetAsSeries function in MQL5.

 

When I read indicator data, the data comes in reverse order (oldest first), but even after using  ArraySetAsSeries , I still can't get the time-series order (newest first).

Here's my function:

int ReadRVI(double &data0[], double &data1[], int count, 
             string symbol, ENUM_TIMEFRAMES period, int ma_period)
{
   int h = iRVI(symbol, period, ma_period);
   
   // Set time-series order
   ArraySetAsSeries(data0, true);
   ArraySetAsSeries(data1, true);
   
   int a;
   a = CopyBuffer(h, 0, 0, count, data0);
   a = CopyBuffer(h, 1, 0, count, data1);
   
   return a;
}

The problem:

  • After calling  ReadRVI ,  data0[0]  should contain the current bar's RVI value

  • data0[1]  should contain the previous bar's RVI value

  • But instead,  data0[0]  still contains the oldest data, not the newest