Docs

fixnan

Fill gaps in a series with the last value seen.

itm
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.

NameKindTypeDefaultRangeDescription
xSeriesnumber--The series whose gaps are to be filled.

Output

NameType
valuenumber

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

itm
fixnan(ta.sma(close, 20))
itm
plot(fixnan(ta.pivothigh(high, 2, 2)), "Last swing high")