MMTMMT Docs
Diagnostics

T409

changing history index needs an explicit series depth

T409

A series whose history depth is inferred cannot use an index that changes while the script runs. Set the history depth explicitly or use a constant index.

Failing example

script "example"
data chart = subscribe(data.ohlcv)
state values = series<float>()
on chart.update {
  let index = int(chart.close ?? 0.0) ?? 0
  let value = values[index]
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
state values = series<float>()
on chart.update { let value = values[1] }

On this page