nz
Replace a missing value with a number, so a gap does not break later math.
nz(x, replacement)The value, or the replacement (0 by default) when it is na.
Parameters
A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
x | Series | number | - | - | The value that may be missing. |
replacement | Series | number | 0 | - | What to use instead of na. |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
- None.
- Missing values
- Never returns na when the replacement is not na. That is the point of it.
Example
nz(ta.sma(close, 20), close)plot(nz(ta.sma(close, 20), close), "Average or close")