Recalculation and confirmation
A bar is either still updating or closed. Three flags let your script tell the two apart, and mark the two positions at the end of the chart where the distinction matters.
| Name | Type | Reports |
|---|---|---|
barstate.isrealtime | series bool | the bar is still updating rather than closed |
barstate.islast | series bool | the bar is the last bar |
barstate.islastconfirmedhistory | series bool | the bar is the last confirmed historical bar |
Each is a series value, so its answer changes from bar to bar.
static float updates = 0.0
if barstate.isrealtime {
updates := updates + 1.0
}Writing for confirmation
If a result must not move once it is drawn, base it on a bar that has closed. The flags above are how you decide which kind of bar you are on.
Every value in the script below is read from the bar the script is being evaluated on. On a bar that is still updating, that bar has not closed.
indicator("Bar range")
plot(high - low)What this page does not tell you
This page states which flags exist and what each reports. It does not state the recalculation contract itself.
Nothing here tells you how often a script is evaluated while a bar is still updating, what triggers each evaluation, what arrives between evaluations, or whether and when a script is evaluated again over bars it has already seen. Do not infer any of that from this page.
For where a run sits in the sequence of bars, see Bar-by-bar evaluation. For the two modes in which a script is handled, see When your code runs, and with what index.