FlowscopeDocs

C006

subscription series is read-only

Severity Error

A series that belongs to a subscription (chart.close, oi.value, funding.rate and so on) is filled by the engine; scripts can read it with [n] but cannot push to it or overwrite its elements, even through another name.

Keep your own derived history in a state rolling buffer and push into that.

Failing example

Flowscope Script
script "Smoothed closes"
data chart = subscribe(data.ohlcv)
plot avg = plot.line(title: "Mean of last 10")
on chart.close {
  chart.close.push(ta.ema(chart.close, 3))
  avg.plot(ta.sma(chart.close, 10))
}

Fixed example

Flowscope Script
script "Smoothed closes"
data chart = subscribe(data.ohlcv)
state smooth = rolling<float>(10)
plot avg = plot.line(title: "Mean of last 10")
on chart.close {
  smooth.push(ta.ema(chart.close, 3))
  avg.plot(smooth.avg())
}