Sidechair

session.islastbar

Browse the reference

True on the last bar of a session, the one after which a new session starts.

Try it in the editor

session.islastbar is true on the final bar of each trading session and false elsewhere. For an intraday chart of a stock that is the last bar of the day, and for 24-hour markets it is the last bar before the daily rollover.

Use it to close positions at the end of the day, to finalise a daily value such as a session high or volume total, or to mark where sessions end. session.isfirstbar is its counterpart at the start.

Type

series bool

Remarks

  • The flag only knows the session is over once the last bar of it has been seen. On a live chart, the bar is not flagged until it is final.
  • session.islastbar_regular is the same test for the regular session only, ignoring extended hours.
  • On Sidechair: true on a bar when the next bar belongs to a different trading day, using the symbol's own trading-day boundary. It is false on the last bar of the chart, because no later bar exists to compare. session.islastbar_regular gives the same result.

Example

Pine ScriptEnd-of-session markerOpen in editor
//@version=6
indicator("Session end", overlay = true)
plot(close, "Close", color.gray)
plotshape(session.islastbar, "Session end", shape.xcross, location.abovebar, color.red, size = size.tiny)

See also

Runs on Sidechair