Download MetaTrader 5

First left bar in window

To add comments, please log in or register
Carry on your private correspondence in your profile. It is secure!
SemperAugustus
20
SemperAugustus 2014.02.10 10:36 
Is there a way to identify the first visible bar on the left in the chart window? That value changes every time when bars are added to the right and when zooming in or out.
qjol
3243
qjol 2014.02.10 10:41  
Simon Gniadkowski
Moderator
17998
Simon Gniadkowski 2014.02.10 10:51  
SemperAugustus:
Is there a way to identify the first visible bar on the left in the chart window? That value changes every time when bars are added to the right and when zooming in or out.

WindowFirstVisibleBar()
SemperAugustus
20
SemperAugustus 2014.02.10 13:18  
Thanks.
whroeder1
14470
whroeder1 2014.02.10 14:19  
                                                         #define WINDOW_MAIN 0
void     GetChartLimits(int&iLeft, int&iRight, double&top, double&bot,int iW=0){
   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
////////////////////////////////////////////////////////////////////////////////
int start(){
   int iL, iR; double pT, pB; GetChartLimits(iL, iR, pT, pB);
   Print("Left most bar started on " + TimeToStr(Time[iL], TIME_MINUTES) );
Not hard if you RTFM
To add comments, please log in or register