CS2204
error A condition cannot be na; write: example
#What it means
A condition (or any bool value) can only be true or false; it can never be na. Here a number or an na is used where a true/false value is needed.
#Typical cause
- A number used as a condition, as in
if (x). - A ternary that gives
naon one side where aboolis needed.
#How to fix it
Write the test you mean, such as !na(x) && x != 0, and use false instead of na for bools.
#Example
//@chartscript 1
indicator("Ready")
const avg = ta.sma(close, 10)
const ready = avg ? 1 : 0
plot(ready)Fixed
//@chartscript 1
indicator("Ready")
const avg = ta.sma(close, 10)
const ready = !na(avg) ? 1 : 0
plot(ready)