Having a rough time understanding IsNaN coding function

MerryDay

Well-known member
VIP
When you search this forum for Isnan, it comes back with 751 examples of it used
eTRAi6g.png
 

mfsteve

Member
VIP
Use IsNaN to test whether a variable is set to a valid number versus N/A:

def myvar1 = 5;
AddLabel(yes, myvar1 + " is a number", if IsNaN(myvar1) then Color.RED else Color.GREEN);

def myvar2 = if close > 3000000 then close else double.nan;
AddLabel(yes, myvar2 + " is not a number", if IsNaN(myvar2) then Color.RED else Color.GREEN);
 

Similar threads

Top