One example would be "sqrt(-1)" which will give you a "-nan".
EDIT: The square root of any negative number.Print( sqrt(-1) );
For an example of "nan" ...
double zero = 0; Print( zero/zero );
It's defined in the IEEE754 Standard.
Yeah , this is the only sqrt i have so i think if the numbers become really really small (not here but down the "process") and they get divided i'll hit a nan ... i assume.
Thanks , where have you been ? I still haven't passed your rating dam it. 😂
Also i guess MathMin can be used to "filter" these out
double zero=0.0; double nan=zero/zero; double inf=3.22/zero; double neg_nan=MathSqrt(-1.0); double positive=1.23; double negative=-1.00*((double)INT_MAX); Print("MathMax(inf,"+positive+")="+MathMax(inf,positive)); Print("MathMin(inf,"+positive+")="+MathMin(inf,positive)); Print("MathMax(inf,nan)="+MathMax(inf,nan)); Print("MathMin(inf,nan)="+MathMin(inf,nan)); Print("MathMax(inf,-nan)="+MathMax(inf,neg_nan)); Print("MathMin(inf,-nan)="+MathMin(inf,neg_nan)); Print("MathMax(nan,-nan)="+MathMax(nan,neg_nan)); Print("MathMin(nan,-nan)="+MathMin(nan,neg_nan)); Print("MathMax(nan,"+positive+")="+MathMax(nan,positive)); Print("MathMin(nan,"+positive+")="+MathMin(nan,positive)); Print("MathMax(-nan,"+positive+")="+MathMax(neg_nan,positive)); Print("MathMin(-nan,"+positive+")="+MathMin(neg_nan,positive)); Print("MathMax(nan,"+negative+")="+MathMax(nan,negative)); Print("MathMin(nan,"+negative+")="+MathMin(nan,negative)); Print("MathMax(-nan,"+negative+")="+MathMax(neg_nan,negative)); Print("MathMin(-nan,"+negative+")="+MathMin(neg_nan,negative));
Then only divide if "MathSqrt(std_x)*MathSqrt(std_y)" is greater than zero.
Also a "log()" of a negative number will also give a "-nan".
Then only divide if "MathSqrt(std_x)*MathSqrt(std_y)" is greater than zero.
Also a "log()" of a negative number will also give a "-nan".
ow , i'm not checking if the covariance is 0.0 , good point .
That must be it , and it indicates many correlations were 0.0 which indicates they may have no data :P- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm getting an exported value of "-nan" to a csv file . I noticed that division by zero on mt5 produces "inf" . What is producing -nan ? if anyone has encountered it of course.
MT5 , not an indicator , not working with reading data live , data is picked up from the hard drive for processing .
Thank you