MMTMMT Docs

Missing values

Handle unavailable history and optional market data without misleading output.

Market data can be unavailable at the beginning of a series, during a gap, or while a calculation is warming up. Scripting v3 represents this explicitly with null.

Preserve an empty result

If a value should not be drawn until it is valid, pass the optional value directly:

on chart.update {
  average.plot(ta.sma(chart.close, 20))
}

The moving average remains empty until it has enough samples.

Supply a fallback deliberately

Use ?? when a fallback genuinely represents what you want:

let volume = chart.volume ?? 0.0

Avoid replacing missing prices with zero merely to make an expression type-check. A zero-price point can distort a chart and imply data that never existed.

Branch when absence changes the meaning

let previous = chart.close[1]
let change: float? = previous == null ? null : (chart.close ?? previous) - previous

This keeps the first result empty rather than reporting a false change from zero.

On this page