Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Script | A 3 line script that tells you how many bars are on your chart

MetaTrader Experts, Indicators, Scripts and Libraries

The following code is deceptively simple and straightforward.

And yet it is also quite useful, especially if you would like to know how many bars are on your chart.

This is always going to be equal to or less than any constraint you have specified through Tools/Options/Charts and Max Bars in Chart, of course, and dependent on the data either downloaded from your broker, or uploaded by you, using a custom symbol, for instance.

I use the built-in iBars function in this instance. All you do is drag the script onto the chart, and look in the experts tab of the Toolbox. 

You can also look at the top left corner of the chart window because I added a Comment line

55976