is it really necessary to use NormalizeDouble() for OrderModify()?

 

You know 'stoploss' and 'takeprofit' are "double" types in OrderModify().

Is it still necessary to use NormalizeDouble() for 'stoploss' and 'takeprofit'? 

 

 

e.g. I saw some EAs use  NormalizeDouble(histroyPrice, Digits) to set the 'stoploss' or 'takeprofit' by OrderModify().

       However, you know the histroyPrice is a double type as accuracy as the Digits number of decimal digits already.

       Is it still necessary to  NormalizeDouble(histroyPrice, Digits) now? Why? Thanks. 

 

It is not necessary in general, but it is necessary after you perform any operation on the double precision number (even a simple sum of two "valid" numbers may lead to an "invalid" number).

And why? It is because the MQL implementation does not bother with adjusting (or tolerating) the double that is not exactly decimal.

 
jollydragon: Is it still necessary to use NormalizeDouble() for 'stoploss' and 'takeprofit'?
  1. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
  2. SL/TP are market orders when triggered, they don't need to be normalized, only abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
  3. Only the open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
  4. Lot size must also be adjusted to a multiple of LotStep. If that is not a power to 1/10 then NormalizeDouble is wrong. Do it right.
 
DeepThought: It is not necessary in general, but it is necessary after you perform any operation on the double precision number (even a simple sum of two "valid" numbers may lead to an "invalid" number). And why? It is because the MQL implementation does not bother with adjusting (or tolerating) the double that is not exactly decimal.
  1. Doubles (Double-precision floating-point format - Wikipedia, the free encyclopedia) are by definition not decimal (Binary-coded decimal - Wikipedia, the free encyclopedia).
  2. They are not invalid. The problem is comparing without understanding The == operand. - MQL4 forum
 
WHRoeder:
  1. Doubles (Double-precision floating-point format - Wikipedia, the free encyclopedia) are by definition not decimal (Binary-coded decimal - Wikipedia, the free encyclopedia).
  2. They are not invalid. The problem is comparing without understanding The == operand. - MQL4 forum

 

Please ignore my inputs. Thank you.

 
WHRoeder:
  1. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
  2. SL/TP are market orders when triggered, they don't need to be normalized, only abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
  3. Only the open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
  4. Lot size must also be adjusted to a multiple of LotStep. If that is not a power to 1/10 then NormalizeDouble is wrong. Do it right.

Dear WHRoeder, Thanks a lot for your clarification and help! 

Reason: