Diagnostics
T449
isLast read inside a close handler
T449
sub.isLast is always false while a close handler runs: the close phase sits on a confirmed period, never on the live edge, so a gate on it inside on sub.close never opens. Move the check into on sub.update, which runs at the live edge; isRealtime stays usable in close handlers.
Failing example
script "conf"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 4)
on chart.close {
let t = chart.time ?? time.fromUnixSeconds(0)
if chart.isLast {
lines.get("hi").set(t, chart.high ?? 0.0, t, chart.high ?? 0.0)
}
}Corrected example
script "fixed"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 4)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
if chart.isLast {
lines.get("hi").set(t, chart.high ?? 0.0, t, chart.high ?? 0.0)
}
}