Download MetaTrader 5

Identifying the value of the decimal number

To add comments, please log in or register
FrKal
24
FrKal  

Hi,

can you please advise me how to program EA to identify the value of just specified decimal?

For example Identify 1.43200 as x.xxx00 (something like "LastTwoAreZeros == true").

The only thing I came with is list all the values I want (for example "if Price = 1.43200 || 1.43300 || 1.43100" etc.) but is there a more automated option?


Thank you for the answers.

FrKal

Taras Slobodyanik
21496
Taras Slobodyanik  
if (NormalizeDouble(Bid,_Digits) == NormalizeDouble(Bid,3))
whroeder1
16822
whroeder1  
FrKal:
can you please advise me how to program EA to identify the value of just specified decimal?

For example Identify 1.43200 as x.xxx00 (something like "LastTwoAreZeros == true").

  1. Round price to the nearest 10 pips MT4:NormalizeDouble - General - MQL5 programming forum
  2. Then see how close price is to it. Doubles are rarely equal. The == operand. - MQL4 forum


Taras Slobodyanik:
if (NormalizeDouble(Bid,_Digits) == NormalizeDouble(Bid,3))
  1. Doubles are rarely equal. The == operand. - MQL4 forum
  2. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
Taras Slobodyanik
21496
Taras Slobodyanik  

Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it.

Show me where it is written in the documentation for MT4 - MT5.
And then I will follow your advice.

Doubles are rarely equal.

Yes you are right.

whroeder1
16822
whroeder1  
Taras Slobodyanik: Show me where it is written in the documentation for MT4 - MT5.
Show me one use where it is correct. It's use is always wrong
FrKal
24
FrKal  

@ Taras Slobodyanik: Thank you, it looks very logical, I do not know why I did not see it.


@ whroeder1: Thank you as well. I get your point but have trouble with understand it (MathNearest and such). I will study your comment and try it and hope I will. Thank you, you push me up.

To add comments, please log in or register