MMTMMT Docs
Diagnostics

T431

collection transform on a series

T431

A series is a history of values over time, not a fixed-size collection, so it has no map, filter, or reduce. Push values into a rolling buffer and transform that, or use a ta.* aggregate.

Failing example

script "conf"
data chart = subscribe(data.ohlcv)
on chart.update {
  let ys = chart.close.map(|x| x * 2.0)
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
state buffer: rolling<float> = rolling<float>(20)
on chart.update {
  buffer.push(chart.close ?? 0.0)
  let ys = buffer.map(|x| x * 2.0)
}

On this page