DBL_MAX bug

 
Hello.
I call Fractal buffer on MT5 With Handle.
            while(FractalBufferUp[c] == EMPTY_VALUE || FractalBufferUp[c] == DBL_MAX || FractalBufferUp[c] == DBL_MAX_10_EXP || FractalBufferUp[c] == DBL_MAX_EXP)
            {
               ++c;             
            }
            
            if(FractalBufferUp[c] != DBL_MAX)
            {
               if(FractalBufferDn[c] == DBL_MAX)
               {
                  Print("WTF");
               }
               ObjectCreate(0,"Quants_SL_UP"+TimeToString(iTime(_Symbol,PERIOD_CURRENT,c)),OBJ_ARROW,0,iTime(_Symbol,PERIOD_CURRENT,c),0);
               ObjectSetInteger(0,"Quants_SL_UP"+TimeToString(iTime(_Symbol,PERIOD_CURRENT,c)),OBJPROP_ARROWCODE,116);
               ObjectSetInteger(0,"Quants_SL_UP"+TimeToString(iTime(_Symbol,PERIOD_CURRENT,c)),OBJPROP_COLOR,UpArrowColor);
               ObjectSetInteger(0,"Quants_SL_UP"+TimeToString(iTime(_Symbol,PERIOD_CURRENT,c)),OBJPROP_WIDTH,ArrowWidth);
               ObjectSetDouble(0,"Quants_SL_UP"+TimeToString(iTime(_Symbol,PERIOD_CURRENT,c)),OBJPROP_PRICE,iHigh(_Symbol,PERIOD_CURRENT,c));
               ObjectSetInteger(0,"Quants_SL_UP"+TimeToString(iTime(_Symbol,PERIOD_CURRENT,c)),OBJPROP_ANCHOR,ANCHOR_UPPER);
            }
Result of this code that it Prints the "WTF" part. While it should not even passed the first IF.
Any idea why ?
 
Ferhat Mutlu: Hello. I call Fractal buffer on MT5 With Handle. Result of this code that it Prints the "WTF" part. While it should not even passed the first IF. Any idea why ?

Floating point numbers (doubles) cannot be compare directly. This has been discussed over and over on this forum. You should do a search before you post.

Here is a recent related thread ... is this comparison safe for non constant data ? - Equality comparison of doubles is not reliable, but it can be dangerous for you.

But there are plenty more on the forum ... just run a search.

 
Fernando Carreiro #:

Floating point numbers (doubles) cannot be compare directly. This has been discussed over and over on this forum. You should do a search before you post.

Here is a recent related thread ... is this comparison safe for non constant data ? - Equality comparison of doubles is not reliable, but it can be dangerous for you.

But there are plenty more on the forum ... just run a search.

Yes found them lately and fixed the issue.
Thanks for the answer still.
Have a nice day

 
Ferhat Mutlu #: Yes found them lately and fixed the issue.

Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what?
          How To Ask Questions The Smart Way. (2004)
     When You Ask.
          Follow up with a brief note on the solution.

 
William Roeder #:

Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what?
          How To Ask Questions The Smart Way. (2004)
     When You Ask.
          Follow up with a brief note on the solution.

For some reason when i was using COPY_BUFFER for last closed candle, Once fractal were repainting , EMPTY_VAL changed to DBL_MAX. That's why when i was looping back to find most recent Fractal, It was printing an arrow there while there is no fractal because of DBL_MAX and it was passing the if != EMPT_VAL condition.

After i started copy buffer for last 100 Bars non stop , DBL_MAX's disappeared and then if != EMPTY_VAL worked..

Previously != DBL_MAX && != EMPTY_VAL was bugged because of the reason Fernando explained. DBL_MAX can't be compared.

Reason: