Cause
In v6, a bool is always true or false. na(), nz() and fixnan() no longer accept bool arguments, so na(prevBullish) doesn't compile.
Broken code
TradingView reports the error on line 5.
//@version=6
indicator("Two up bars")
bullish = close > open
prevBullish = bullish[1]
plot(na(prevBullish) ? 0 : prevBullish and bullish ? 1 : 0)Fixed code
The same script, corrected for Pine Script v6. Paste it into the Pine Editor and save.
//@version=6
indicator("Two up bars")
bullish = close > open
prevBullish = bullish[1]
plot(prevBullish and bullish ? 1 : 0)Why it works
On the first bar, bullish[1] has no previous bar to read. In v5 that returned na; in v6 it returns false. The na check is no longer needed: the expression is simply false on the first bar. If you need to know whether a previous bar exists, test the bar itself with bar_index > 0.
nz() and fixnan() on bools
nz(myBool) fails the same way: Cannot call "nz" with argument "source"="up". An argument of "series bool" type was used but a "simple int" is expected. Remove the nz(): a v6 bool already falls back to false.
Questions
How do I check if a bool is na in Pine Script v6?
You can't, because it never is: v6 bools are only true or false. If you need three states (true, false, unknown), use an int such as 1, -1 and 0, or a second bool that records whether the first has been set.
What does a bool with [1] return on the first bar in v6?
false. In v5 it returned na, which is why older scripts wrapped it in na() or nz().
The scripts on this page are minimal examples written to show the error and its fix, not trading systems. Trading involves substantial risk of loss and is not suitable for every investor. Edgoro is a software tool, not a broker or financial adviser: nothing it produces is investment advice, and past or backtested performance does not guarantee future results.