MMTMMT Docs
Diagnostics

C007

series cannot be saved or passed here

C007

A series reference can be returned from a function or kept in a collection the caller owns. It cannot be re-bound in state, and a local collection of series references cannot be saved into state. Declare the collection in state and fill it there.

Failing example

script "example"
type Bucket { values: series<float>[] }
data chart = subscribe(data.ohlcv)
state bucket: Bucket = Bucket { values: series<float>[](2) }
on chart.update {
  let temporary: series<float>[] = series<float>[](2)
  bucket.values = temporary
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
on chart.update {
  let temporary: series<float>[] = series<float>[](2)
  let count = temporary.len
}

On this page