session.islastbar_regular - Pine Script Variable
session.islastbar_regular
Section titled “session.islastbar_regular”Overview
Section titled “Overview”Returns true on the last regular session bar of the day, false otherwise. The result is the same whether extended session information is used or not.
boolQualifier
Section titled “Qualifier”series
Remarks
Section titled “Remarks”- This variable is not guaranteed to return true once in every session because the last bar of the session might not exist if no trades occur during what should be the session’s last bar.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6strategy("`session.islastbar_regular` Example", overlay = true)longCondition = year >= 2022// Place a long order at the `close` of the trading session's first bar.if session.isfirstbar and longConditionstrategy.entry("Long", strategy.long)// Close the long position at the `close` of the trading session's last bar.if session.islastbar_regular and barstate.isconfirmedstrategy.close("Long", immediately = true)