AlertaScript / Documentation
Execution model
Know what can change before the bar closes.
How it works
Scripts calculate against chart bars and update as current data changes. Historical bars have completed OHLCV values; a live bar is still forming. var preserves initialized state across bars, while history references read earlier series values.
Put it into practice
Use barstate.isconfirmed when a rule explicitly requires a completed candle. Test both historical results and live updates. After a symbol, timeframe or input change, a script may recalculate over the available dataset; do not treat in-memory state as permanent storage.
Working example
AlertaScript
indicator("Confirmed close", overlay=true)value = barstate.isconfirmed ? close : naplot(value, "Confirmed close", style=plot.style_circles)