NormalizeDouble compare problems

 
Hi All

I wonder if somebody can advise me, I know there are issues regarding comparing double numbers, and I was lead to believe that using Normalizedouble was the solution but my compare I still not working correctly.
Here is my compare code
OrderSelect(tickarray[2],SELECT_BY_TICKET,MODE_TRADES);
modify = NormalizeDouble(OrderOpenPrice(),4);
modify1 = NormalizeDouble (OrderTakeProfit(),4);
OrderSelect(tickarray[1],SELECT_BY_TICKET,MODE_TRADES);
modify2 = NormalizeDouble(OrderTakeProfit(),4);
if ((modify+(PipsToProtect*Point)) == modify1 &&  (modify+(PipsToProtect*Point))== modify2)


Do I need to do two compares one for 4 decimal places and one for three decimal places?

Any Help is most appreciated
Thanks
madmarkym

 
modify+(PipsToProtect*Point) is not normalized double. In common case you cannot compare 2 doubles for equality even if your doubles are normalized. See our function CompareDoubles in the stdlib.mq4 library sample

Welcome to mql4.com. Problem with comparison of 2 doubles was discussed many times
"MQL4: A Problem with Bid =="
"MQL4: int x = double y ?"
 
Thanks for the advice and sorry for the duplicate post
madmarkym
 
Hi

I am trying to get my head around the double problems and have tried to do a bit of recoding would this alternative code work, I have tried it but it still does not seem to work, can you see were I have gone wrong

OrderSelect(tickarray[2],SELECT_BY_TICKET,MODE_TRADES);
modify = OrderOpenPrice();
modify1 = OrderTakeProfit();
OrderSelect(tickarray[1],SELECT_BY_TICKET,MODE_TRADES);
modify2 = OrderTakeProfit();
if  (NormalizeDouble(((modify+(PipsToProtect*Point)) - modify1),4) == 0 &&  NormalizeDouble(((modify+(PipsToProtect*Point))- modify2),4)==0){// process order}


Many Thanks for your time
madmarkym

Reason: