MQL4参考 图表操作 WindowFirstVisibleBar

WindowFirstVisibleBar

Returns index of the first visible bar in the current chart window.

int  WindowFirstVisibleBar();

Parameters

None.

Returned value

Index of the first visible bar number in the current chart window.

Note

It must be taken into consideration that price bars are numbered in the reverse order, from the last to the first one. The current bar, the latest in the price array, is indexed as 0. The oldest bar is indexed as Bars-1. If the first visible bar number is 2 or more bars less than the amount of visible bars in the chart, it means that the chart window has not been fully filled out and there is a space to the left.

Example:

   // work with visible bars.
   int bars_count=WindowBarsPerChart();
   int bar=WindowFirstVisibleBar();
   for(int i=0; i<bars_count; i++,bar--)
     {
      // ...
     }