fixnan() - PineScript Function
fixnan()
Section titled “fixnan()”Overview
Section titled “Overview”fixnan() forward-fills a series by replacing each na with the last non-na value. Use it when data sources produce occasional gaps.
Syntax
Section titled “Syntax”fixnan(source) → series _Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
source | series _ | Series to forward-fill (any type except tuples). |
Returns
Section titled “Returns”Series without na gaps.
Remarks
Section titled “Remarks”- Unlike
nz(),fixnan()forward-fills the last non-navalue but does not substitute an arbitrary default when all previous values arena. - Works on numbers, colors, strings, and bool series.
Examples
Section titled “Examples”//@version=5indicator("fixnan example", overlay=false)
extClose = request.security(syminfo.tickerid, "60", close)filled = fixnan(extClose)
plot(extClose, "Raw", color=color.new(color.red, 40))plot(filled, "Forward filled", color=color.blue)