Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

pine-script

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?

like image 484
SG Tech Edge Avatar asked Dec 01 '25 20:12

SG Tech Edge


1 Answers

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

like image 55
Bjorn Mistiaen Avatar answered Dec 04 '25 00:12

Bjorn Mistiaen