MMTMMT Docs
Diagnostics

T422

book and profile views only live for the current update

T422

An order-book or volume-profile view is valid only during the update that produced it. Read what you need right away instead of storing it in state, records, or collections, or passing it out of a function.

Failing example

script "conf"

data chart = subscribe(data.ohlcv)
data book = subscribe(data.book)
state v: BookLevels? = null

on chart.update {
  let x = book.bids()
  let n = x == null ? 0 : x.len
}

Corrected example

script "fixed"
data chart = subscribe(data.ohlcv)
data book = subscribe(data.book)
on chart.update { let levels = book.bids()
  let first = levels.get(0) }

On this page