MMTMMT Docs
Diagnostics

T418

subscription must refer to one known data source

T418

A subscription must be known when the script is compiled and cannot be chosen from a value computed while it runs. Use the data binding directly, or a constant key or index.

Failing example

script "conf"

data (
  a = subscribe(data.ohlcv)
  b = subscribe(data.ohlcv, timeframe: 5m)
)

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

fn cls(s: OhlcvData) -> float { return s.close ?? 0.0 }

on a.update {
  let flip = (a.close ?? 0.0) > 101.0
  out.plot(cls(flip ? a : b))
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
on chart.update { let close = chart.close }

On this page