MMTMMT Docs
Diagnostics

P011

top-level statement is not a declaration

P011

Executable statements are not legal at file scope. Move the statement into a function or handler.

Failing example

script "conf"

setup fam = for tf in [tf("2m"), tf("5m")] {
  subscribe(data.ohlcv, timeframe: tf)
}

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

on fam.close(a, b, c) { out.plot(1.0) }

Corrected example

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

On this page