True on the bar that is forming now, while the market is trading, and false on every closed historical bar.
barstate.isrealtime is false for every bar the chart loaded from history and true for bars that arrive live. On the forming bar the script runs once per tick, and the value is true on each of those runs.
Use it to behave differently live than on history: draw an extra marker, send an alert only for fresh bars, or skip a calculation that cannot run on old data. barstate.ishistory is its opposite.
Type
series bool
Remarks
- A script that needs history and live bars to agree should not depend on
barstate.isrealtime, because the live path runs more often than the history path. - On Sidechair: true only on the last bar, and only when the host reports that the market is trading. On a closed market or a pure history chart it is false on every bar.
Example
//@version=6
indicator("Live bar", overlay = true)
plot(close, "Close", color.gray)
bgcolor(barstate.isrealtime ? color.new(color.orange, 80) : na)See also
Runs on Sidechair