TradingCharts

Sessions

A session is a time window within a trading day. ChartScript represents a session as a string in HHMM-HHMM form, optionally followed by a day-of-week filter :1234567 (1 = Sunday, 7 =…

session.* booleans

Name Value
session.ismarket Always true — executions run on regular-session data only.
session.ispremarket Always false (no extended-hours bars are served).
session.ispostmarket Always false.
session.isfirstbar The first bar of a session.
session.islastbar The last bar of a session.
session.isfirstbar_regular First bar of the regular (non-extended) session.
session.islastbar_regular Last bar of the regular session.

time(timeframe, session) for session membership

inRth = not na(time(timeframe.period, "0915-1530:12345", "Asia/Kolkata"))
  • Returns the bar's time inside the session, na outside.
  • Pair with a timezone argument when the session is defined in a non-exchange zone.

Example — tint the opening range

Because there are no extended-hours bars, session tinting is done with time(tf, session):

inOpening = not na(time(timeframe.period, "0915-0930:23456"))
bgcolor(inOpening ? color.new(color.orange, 92) : na)

Example — reset at session open

openPrice = na
if session.isfirstbar
    openPrice := open
plot(openPrice, "RTH open", style=plot.style_stepline, color=color.gray)

See also