Sidechair

barstate.islastconfirmedhistory

Browse the reference

True on the last bar that was already closed when the script loaded, just before live bars begin.

Try it in the editor

barstate.islastconfirmedhistory marks the final historical bar. On a live chart that is the bar immediately before the forming one. On a chart with no live bar it is the last bar, and then barstate.islast is true on the same bar.

It gives you one place to run history-only work after all closed bars have been seen, such as printing a final value, without it repeating on every tick of the live bar the way barstate.islast does.

Type

series bool

Remarks

  • It is true on exactly one bar per script run, and never on a bar that arrives in real time.
  • On Sidechair: on a live chart it is true one bar before the last bar. With no live market it is true on the last bar.

Example

Pine ScriptMark the end of historyOpen in editor
//@version=6
indicator("End of history", overlay = true)
plot(close, "Close", color.gray)
bgcolor(barstate.islastconfirmedhistory ? color.new(color.orange, 70) : na)
if barstate.islastconfirmedhistory
    label.new(bar_index, low, "End of history", style = label.style_label_up)

See also

Runs on Sidechair