Variables
barstate.isrealtime
The bar under evaluation is still updating rather than closed. Once that bar has closed, your script reads false. It is how your script tells the two kinds of bar apart. If a result must not move once it is drawn, base it on a bar that has closed.
Example
indicator("BarState.isrealtime Background Example", overlay=true)
// Change background color if the bar is real-time
bgcolor(barstate.isrealtime ? color.red : na)
Type
series bool