Is SERIES_BARS_COUNT correct?

 

I made a simple test indicator for printing the number of bars.

//+------------------------------------------------------------------+
//|                                                     testBars.mq5 |
//+------------------------------------------------------------------+
#property description "Test Bars Indicator:"
#property description ""
#property description "Get the number of bars available"
#property description "for the current symbol and chart period."
//--------------------------------------------------------------------
#property indicator_chart_window
int OnInit() { return(0); }
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& spread[])
  {
   Print
     (
           "SERIES_BARS_COUNT = ",  SeriesInfoInteger(Symbol(),0,SERIES_BARS_COUNT),",  ",
           "Bars = ",               Bars             (Symbol(),0),                  ",\n",
           "rates_total = ",        rates_total,                                    ",  ",
           "prev_calculated = ",    prev_calculated,                                ".\n",

           "SERIES_FIRSTDATE = ",   TimeToString(SeriesInfoInteger(Symbol(),0,SERIES_FIRSTDATE),   TIME_DATE|TIME_SECONDS),",  ",
           "time[0] = ",            time[0],                                                                               ",\n",
           "SERIES_LASTBAR_DATE = ",TimeToString(SeriesInfoInteger(Symbol(),0,SERIES_LASTBAR_DATE),TIME_DATE|TIME_SECONDS),",  ",
           "time[rates_total-1] = ",time[rates_total-1],                                                                   "."
     );
   return(rates_total);
  }

Printed results are like this.

testBars (EURJPY,M1) 00:56:09 SERIES_BARS_COUNT = 50000,  Bars = 50000,
testBars (EURJPY,M1) 00:56:09 rates_total = 50004,  prev_calculated = 50003.
testBars (EURJPY,M1) 00:56:09 SERIES_FIRSTDATE = 2010.05.26 15:29:00,  time[0] = 2010.05.26 15:29:00,
testBars (EURJPY,M1) 00:56:09 SERIES_LASTBAR_DATE = 2010.07.14 17:56:00,  time[rates_total-1] = 2010.07.14 17:56:00.

SERIES_BARS_COUNT is always equal to Bars.
Is it really correct?

I think SERIES_BARS_COUNT should be equal to rates_total...

Documentation on MQL5: Timeseries and Indicators Access / Bars
  • www.mql5.com
Timeseries and Indicators Access / Bars - Documentation on MQL5
 

Is Nobady in trouble?
So, I change my form of question.

If the current chart is EUR/USD,
and if I want to get rates_total of USD/JPY, 
how can I get it?

 
Micky:

Is Nobady in trouble?
So, I change my form of question.

If the current chart is EUR/USD,
and if I want to get rates_total of USD/JPY, 
how can I get it?

If you wanted to get bars count of USDJPY  PERIOD_M1 (for example) you should use Bars("USDJPY",PERIOD_M1). If you wanted to get rates, you should use CopyRates function or you can get calculated data of any indicator using CopyBuffer function (in this way you should create a handle to this indicator before). 

What for you want to get rates_total of USDJPY when current symbol of your indicator is EURUSD?

If you want to build muti-currency indicator please read this article.

 

Thanks for your reply, alexvd.

Surely I want to build somthing like muti-currency indicator.
But I want to use Technical Indicator Functions like iRSI() or iMACD() or iStochastic() etc...

All these Functions return only the handle of a specified technical indicator.
And if you want to check whether the handle is available or not, you need to compare a return value of BarsCalculated(handle) with "rates_total".

//--- check if all data calculated
   if(BarsCalculated(handle)<rates_total) return(0);

This check is showed in Example of MQL5 Reference / Timeseries and Indicators Access / CopyBuffer.
But this example is single-symbol indicator.

If the current chart is EURUSD and if I get a handle like this:

   ExtRSIHandle=iRSI("USDJPY",_Period,14,PRICE_CLOSE);

this case, what should I compare the return value of BarsCalculated(ExtRSIHandle) with?

"rates_total" isn't it, because "rates_total" is number of bars count of EURUSD.
Bars("USDJPY",_Period) isn't it, because Bars("USDJPY",_Period) is number of bars count in the history.

SeriesInfoInteger("USDJPY",_Period,SERIES_BARS_COUNT) should be it, I guess...but, this may not be it.

 

Thank you, Micky, for your report.

Fixed 

 
stringo:

Thank you, Micky, for your report.

Fixed 

Really?

So I'll wait for update.

Thank you. 

Reason: