True on the first bar of a session, the one that opens a new trading day.
session.isfirstbar is true on the first bar of each trading session and false on the others. On a stock chart with extended hours it is the first pre-market bar of the day. On a 24-hour market it is the first bar after the daily rollover.
Use it to reset a value that restarts each day, such as a session VWAP, a high and low of the day, or an opening range. session.isfirstbar_regular marks only the first bar of the regular session.
Type
series bool
Remarks
- The first bar of a session is found from the exchange schedule, so a chart whose history starts mid-session does not report true on its first bar.
- On Sidechair: true when the bar's trading day differs from the previous bar's, using the symbol's own day boundary. It is the same as
session.isfirstbar_regular, and the first bar of the loaded data counts as a session start.
Example
//@version=6
indicator("Session open", overlay = true)
var float sessionOpen = na
if session.isfirstbar
sessionOpen := open
plot(sessionOpen, "Session open", color.orange, 2)
plot(close, "Close", color.gray)See also
Runs on Sidechair