Skip to content
Algo Trade Analytics Docs

na - Pine Script Variable

A keyword signifying “not available”, indicating that a variable has no assigned value.

na

simple

  • Use the na() function to test values. Direct comparison (value == na) is invalid.
  • Initialize typed variables with na before assigning their first real value.
  • Do not use this variable with comparison operators to test values for na, as it might lead to unexpected behavior. Instead, use the na function. Note that na can be used to initialize variables when the initialization statement also specifies the variable’s type.
//@version=6
indicator("Warm-up guard", overlay=false)
len = input.int(20, "SMA length")
value = bar_index < len ? na : ta.sma(close, len)
plot(value)