Skip to content

session ​

How do you find the first bar of each session? Not with session.isfirstbar: this engine doesn't follow sessions bar by bar, so session.ismarket is always true and the other flags are always false. Test the trading day instead, which changes on a session's first bar.

pine
//@version=6
indicator("Each session's open", overlay = true)
// session.isfirstbar is always false here, so watch the trading day change
newDay = ta.change(time_tradingday) != 0
var float dayOpen = na
if newDay
    dayOpen := open
plot(dayOpen, "Session open", color.orange, style = plot.style_stepline)

To test whether a bar sits inside given hours, pass a session to time, which reads na outside it. See sessions.

The session flags never move

A script written for TradingView that waits for session.isfirstbar, session.islastbar or session.ispremarket never acts here, and one that skips bars outside session.ismarket skips none.

session.ismarket ​

Pine v6No effect here
pine
series bool session.ismarket

Always true here, whatever the bar's hours.

session.is* ​

No effect here

The other session flags, each always false here.

Each is a series bool.

session.* ​

The session kinds, for the session argument of time and time_close.

Each is a const string.

NameWhat it means
session.extendedThe symbol's extended hours: NYSE's from 04:00 to 20:00 for a symbol on New York's clock, else the same as session.regular.
session.regularThe symbol's regular trading hours.

AmenoScript is compatible with Pine Script v6. Pine Script is a trademark of TradingView, Inc., which has no part in AmenoScript.