check if variable is NA

Viewed 1959

I use pine script and I want to check if some variable is NA. Say:

float value = na

if value == na
   // do something

As far as I am aware, the manual says that it is not guaranteed to work. Are there any alternatives to check if a variable is NA? I can't assign it to 0 though, since the outcome value can be 0.0 in my script. I am new to Pine Script. Thanks!

1 Answers

You should use the na() function :

if na(value)
     // do something
Related