FlowscopeDocs

P005

`??` mixed with `&&` or `||` needs parentheses

Severity Error

An expression combines the null-coalescing operator ?? with && or || without parentheses. Whatever precedence the parser picks, a reader can easily assume the other one, so the combination must be grouped explicitly.

Wrap the part you mean in parentheses, typically the coalescing part: (armed ?? false) && chart.isRealtime.

Failing example

Flowscope Script
script "Armed breakout"
data chart = subscribe(data.ohlcv)
state armed: bool? = null
alert hit = alert(title: "Breakout while armed")
on chart.close {
  if armed ?? false && chart.isRealtime {
    hit.trigger()
  }
  armed = chart.close > chart.high[1]
}

Fixed example

Flowscope Script
script "Armed breakout"
data chart = subscribe(data.ohlcv)
state armed: bool? = null
alert hit = alert(title: "Breakout while armed")
on chart.close {
  if (armed ?? false) && chart.isRealtime {
    hit.trigger()
  }
  armed = chart.close > chart.high[1]
}