Reputation: 507
I want to label the last bar in the current window. barstate.islast
is true only for the overall last bar in the whole dataset. I need to figure out the last bar that is displayed on my window. Is this possible?
Upvotes: 2
Views: 5624
Reputation: 3108
Now with Pinescript v5, you can get the number of the visibles bars on your screen.
Just import this open library
import mentalRock19315/NumberOfVisibleBars/3
And then you can get the number of the visibles bars in a variable of your choice :
a = NumberOfVisibleBars. NumberOfVisibleBars()
Upvotes: 0
Reputation: 6905
Unfortunately, this is not possible in Pine.
There's no way to interact with what's shown in the window.
Edit 1 : last_bar_index
While it's still not possible to get the last bar that is displayed in the window, it is now possible to get the bar_index
of the last bar in the set of bars, by using the built-in variable last_bar_index
Upvotes: 3