MMTMMT Docs
Diagnostics

T413

indicator length must be known before the script runs

T413

An indicator window length must be known when the script is compiled. Use a literal, a constant expression, or an input default.

Failing example

script "conf"

data chart = subscribe(data.ohlcv)

plot out = plot.line(title: "out")

state period = 20

on chart.update {
  period += 1
  out.plot(ta.sma((chart.close ?? 0.0), period))
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
on chart.update { let average = ta.ema(chart.close, 3) }

On this page