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

 

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate/OnStart (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
          MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
          How to call indicators in MQL5 - MQL5 Articles (2010)