barstate.isconfirmed: it is true on historical bars (all but the last while the market is open) and, on the bar still forming, false until the bar closes. Each flag
is a bool series, so it answers for the bar the script is on.
The seven flags
barstate.islast and barstate.islastconfirmedhistory are separate flags; do not use one expecting the other. On a live chart
islast is true on the forming bar, so a script that draws on it runs again on every tick. With calc_on_every_tick=false the forming bar does not run until it closes (see Recalculation and confirmation); an intra variable keeps a value across the runs of one forming bar (see Values that persist across bars).