WindowBarsPerChart() problem

 

Hi there,

I have a problem with the WindowBarsPerChart() function (see attached screenshot) that I hope someone can help me with.

The screenshot shows a standard chart that I have scrolled all the way to the right so that the rightmost bar is bar 0.

I run a simple script that prints the values of WindowBarsPerChart() and WindowFirstVisibleBar(), the output of which you can see in the Experts tab of the screenshot.

WindowBarsPerChart returns a value of 39 and WindowFirstVisibleBar returns a value of 39.

If you count the bars on the screenshot right to left starting at 0 then the leftmost bar (the first visible bar) is indeed 39 which is correct which means there are 40 bars visible on the chart.

However WindowBarsPerChart() returns a value of only 39 which is incorrect since the value should be actually 40.

Can anyone offer any insight as to why WindowBarsPerChart() appears to return an incorrect value?

Regards,

Laurence.


Bars.jpg

 
Hello
Value of "WindowFirstVisibleBar()" function strictly depends on screen position of bar number zero.
Try to move bar number zero precisely by <F12> and <Shift-F12> keys and you will see this dependence.
Also take look at Chart metrics.
Best regards
Ais
Reason: