Pine Script na() Function: Handling Missing Data in TradingView
Your Pine Script just crashed on bar one. The chart's blank, there's an error you don't understand, and you're losing time. I've debugged this exact problem on a TSLA strategy back in January — missing data on the first bars was always the cause. In Pine Script, na() (short for "not available") is the built-in function that checks whether a value is missing or undefined. It returns true when a value is na, false when it exists. That's it. Simple, but it'll save you hours of frustration.





