fixnan
Fill gaps in a series with the last value seen.
fixnan(x)The last non-na value, carried forward. Unlike nz(x, 0), which substitutes a constant and drops a series to zero in a gap, this holds the series where it was, which is what a gap in a feed usually means. It never looks ahead: a gap before the first observation stays 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 series whose gaps are to be filled. |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
- 1 bar.
- Missing values
- na until the first non-na observation, and never na after it: every later gap is filled with the last value seen.
Example
fixnan(ta.sma(close, 20))plot(fixnan(ta.pivothigh(high, 2, 2)), "Last swing high")