How to get the last bar index of the currently displayed bars in the window?

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?


Solution 1:

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