Variables
barstate.isnew
Returns true if script is currently calculating on new bar, false otherwise. This variable is true when calculating on historical bars or on first update of a newly generated real-time bar.
Example
indicator("BarState.new Example", overlay=false)
// Create a signal that is 1 when a new bar forms, otherwise 0
new_bar_signal = ta.change(bar_index) ? 1 : 0
// Plot the signal to visualize new bar formations
plot(new_bar_signal, color=color.green, style=plot.style_histogram, title="New Bar Signal")
Type
series bool