iBars() has a bug, the return value is larger than the "Max bars in chart" parameter in platform settings.

 
//+------------------------------------------------------------------+
//|                                     test_iBars_iTime_MAXBARS.mq5 |
//|                                           Copyright 2019,fxMeter |
//|                            https://www.mql5.com/en/users/fxmeter |
//+------------------------------------------------------------------+
//2019-4-9 10:47:26
#property copyright "Copyright 2019,fxMeter"
#property link      "https://www.mql5.com/en/users/fxmeter"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 
//--- MAX_BARS = 10000
   int max=TerminalInfoInteger(TERMINAL_MAXBARS); //=10000
   int bars=iBars(Symbol(),Period()); //= 10250 ?
   printf("max = %d, iBars = %d",max,bars);
   printf("the first time in max   = %s",(string)iTime(Symbol(),Period(),max-1));
   printf("the first time in bars  = %s",(string)iTime(Symbol(),Period(),bars-1));

  }
//+------------------------------------------------------------------+


 

Tested on MT5 Version 5.00 build 2007.

 
That's not a bug. Some overflow are allowed and happens all the time.
 

The return value of iBars(...) is the same  as SeriesInfoInteger(Symbol(),Period(),SERIES_BARS_COUNT)


Forum on trading, automated trading systems and testing trading strategies

List of changes in MetaTrader 5 Client Terminal builds

MetaQuotes Software Corp., 2010.07.20 11:16

MetaTrader 5 Client Terminal build 294

  1. Terminal: Fixed saving of data and the location of windows at the shutdown of the operating system.
  2. Terminal: In the Navigator added showing of the number of available Expert Advisors, scripts and indicators in the Code Base section of MQL5.com.
  3. Terminal: Revised the mechanism of object magneting - now point time binding is always performed with a minute precision, which saves layouts when switching to smaller timeframes.
  4. Terminal: Revised the account opening window - now you can add addresses of trade servers.
  5. Terminal: Fixed the calculation of the maximum and minimum of the scale of indicators drawn in a separate window.
  6. Terminal: Added support of standard hotkeys in the HTML editor of emails in the internal mail system.
  7. MetaEditor: In the 64-bit version, fixed switching to the terminal by pressing the F4 key.
  8. MQL5: Improved the performance of the 64-bit version.
  9. MQL5: Fixed error with the return of a structure from a function by value.
  10. MQL5: Changed the value returned by the SERIES_BARS_COUNT symbol property - now it always returns the available number of bars, irrespective of the maximum set in the terminal settings.
  11. Tester: Increased the speed of optimization.
  12. Tester: Added display of indicators used by the Expert Advisor when displaying the chart of testing results (in the 'Open Chart' command of testing results).
  13. Tester: Added displaying of messages about the mismatch of versions of EX5 files.
  14. Tester: Fixed scrolling of the list of parameters when during testing.
  15. Tester: Fixed the completion of the agent operation in case of an error during the launch of testing.
  16. Fixed errors reported on the forum and in crash logs.

The live update is available through the live update system.

The MetaTrader 5 client terminal can be downloaded athttps://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe




Should the document be updated?

https://www.mql5.com/en/docs/series/ibars

Documentation on MQL5: Timeseries and Indicators Access / iBars
Documentation on MQL5: Timeseries and Indicators Access / iBars
  • www.mql5.com
The number of bars of a corresponding symbol and period, available in history, but no more than allowed by the "Max bars in chart" parameter in platform settings.
 
Alain Verleyen:
That's not a bug. Some overflow are allowed and happens all the time.

I don't think so.

 
Ziheng Zhuang #:

I don't think so.

From my experience, when a chart has been open it accumulates more bars than max bars on chart.

So, if max bars on chart is 10,000, when an M1 chart is first opened, it contains 10,000 bars.  But when it has been open for 10 minutes, it has 10,010 bars.

Therefore the function returns 10,010.  The "bug" I think is in the documentation, not the function.  I think the documentation just needs to clarify this fact.

Reason: