Skip to content

fixnan() - PineScript Function

fixnan() forward-fills a series by replacing each na with the last non-na value. Use it when data sources produce occasional gaps.

fixnan(source) → series _
NameTypeDescription
sourceseries _Series to forward-fill (any type except tuples).

Series without na gaps.

  • Unlike nz(), fixnan() forward-fills the last non-na value but does not substitute an arbitrary default when all previous values are na.
  • Works on numbers, colors, strings, and bool series.
//@version=5
indicator("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)