FlowscopeDocs

P009

postfix `!` is not supported

Severity Error

A postfix ! (a “non-null assertion”) is not part of the language. Flowscope Script never lets you claim that a value is present without checking it, because a missing bar or an empty book is a normal situation in market data.

Check the value with if x != null first, or provide a fallback with x ?? fallback.

Failing example

Flowscope Script
script "Body size"
data chart = subscribe(data.ohlcv)
plot body = plot.histogram(title: "Body")
on chart.close {
  let c = chart.close!
  let o = chart.open!
  body.plot(math.abs(c - o))
}

Fixed example

Flowscope Script
script "Body size"
data chart = subscribe(data.ohlcv)
plot body = plot.histogram(title: "Body")
on chart.close {
  let c = chart.close
  let o = chart.open
  if c != null && o != null {
    body.plot(math.abs(c - o))
  }
}