zwp
Pine Script Scholar
Pine Script Scholar
Posts: 17
Joined: September 18th, 2021
Contact: TradingView Profile

blank persistent variable

Hey all,
I have one short question. Is:

Code: Select all

var float t_stop = na
the same as

Code: Select all

var t_stop = 0.0
if not, please can you explain the difference in your answer.
Thanks upfront.

purplemint22
Pine Script Rookie
Pine Script Rookie
Posts: 17
Joined: October 14th, 2022

Re: blank persistent variable

Yes and no. They are both same data type, but var t_stop = 0.0 contains an actual value and var float t_stop = na does not. So you can see the difference when you try to plot the variables by themselves.

var float t_stop = na will display an empty box, and var t_stop = 0.0 will display a horizontal line at 0.0.

zwp
Pine Script Scholar
Pine Script Scholar
Posts: 17
Joined: September 18th, 2021
Contact: TradingView Profile

Re: blank persistent variable

Thank you!

Return to “Pine Script Q&A”