# OnCalculate question

MQL5 Cloud Network speeds up calculations. Try it!
890
2012.08.28 01:24

Hello,

my question is about the order of prices in price arrays passed to OnCalcuate. I know, there are many tags for this subject, however,

my problem is this:

Now the problem: The sample below outputs on each tick CURRENT close and also "as series". I thought §as series§ means that LATEST value always indexed=0 ? Can anyone clarify ? (close[0] returns always stale or very old value)

```int OnCalculate (const int rates_total,      // size of input timeseries
const int prev_calculated,  // bars handled in previous call
const datetime& time[],     // Time
const double& open[],       // Open
const double& high[],       // High
const double& low[],        // Low
const double& close[],      // Close
const long& tick_volume[],  // Tick Volume
const long& volume[],       // Real Volume
)

{
int begin=0;

if(rates_total < period_momentum-1+begin)
{

return(0);// not enough bars for calculation
}

string msg=StringFormat("close[0]=%.5f close[%d]=%.5f"
,close[0],rates_total-1,close[rates_total-1]);
Print(msg);

if(ArrayIsSeries(close) == true)
Print("as series");

return(rates_total);
}
```

Thank you

685
2012.08.28 11:00

Hello,

my question is about the order of prices in price arrays passed to OnCalcuate. I know, there are many tags for this subject, however,

my problem is this:

Now the problem: The sample below outputs on each tick CURRENT close and also "as series". I thought §as series§ means that LATEST value always indexed=0 ? Can anyone clarify ? (close[0] returns always stale or very old value)

Thank you

https://www.mql5.com/en/docs/series/bufferdirection
Documentation on MQL5: Timeseries and Indicators Access / Indexing Direction in Arrays, Buffers and Timeseries
• www.mql5.com
Timeseries and Indicators Access / Indexing Direction in Arrays, Buffers and Timeseries - Documentation on MQL5
890
2012.08.28 14:15

Hello,

... "Timeseries are arrays with reverse indexing"

So what i describe is that in my case Timeseries is NOT reverse indexed....

What do i wrong ?