Variables
barstate.ishistory
Tells your script whether the bar it is being evaluated on is a historical bar. On a bar that is not historical it reads false. The value is a series, so the answer it gives changes as the script moves from bar to bar.
Example
indicator(title="barstate.ishistory Example", overlay=true)
static float barHigh = na
barHigh := high
histValue = barstate.ishistory ? barHigh : 0
realtimeValue = barstate.ishistory ? 0 : barHigh
plot(histValue, color=color.blue, title="Historical High")
plot(realtimeValue, color=color.red, title="Real-time High")
Type
series bool