Count Visible bars on screen

 
What function is available for showing total number of bars visible on chart window?
 
Arpit T:
What function is available for showing total number of bars visible on chart window?

https://www.mql5.com/en/docs/constants/chartconstants/charts_samples#chart_visible_bars

Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Examples of Working with the Chart
Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Examples of Working with the Chart
  • www.mql5.com
Examples of Working with the Chart - Chart Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
                                                         #define WINDOW_MAIN 0
void     GetChartLimits(int&iLeft, int&iRight, double&top, double&bot,int iW=0){
      /* MT4 build 445: In the tester (visual mode,) on the first tick, these
       * routines return left=100, right=37 (depends on default bar scaling.)
       * This is what the chart looks like when you maximize it while it is
       * generating the FXT file. On ticks after that, it appears like the
       * left/right are correct but the hi/lo are one tick behind the displayed
       * chart. On the start of a new bar, the hi/lo can be off when a recent
       * extreme drops off but the scale hasn't resized. I tried calling
       * WindowRedraw() first but that did not change results. I don't know
       * about live charts.                                                   */
   top      = WindowPriceMax(iW);   iLeft    = WindowFirstVisibleBar();
   bot      = WindowPriceMin(iW);   iRight   = iLeft-WindowBarsPerChart();
   if(top-bot < pips2dbl)  top    = bot+pips2dbl;     // Avoid scroll bug / div0
   if(iRight < 0)          iRight = 0;                // Chart is shifted.
}  // GetChartLimits
Use Migrating from MQL4 to MQL5 - MQL5 Articles № 19 to convert to MT5.
Reason: