# NormalizeDouble() not working

165

```StopLossBuy    = NormalizeDouble(Low[2] - 0.0003, Digits()); 	//1.1304799999999999
StopLossBuy    = NormalizeDouble(Low[2] - 0.0003, 5); 		//1.1304799999999999```

I have tried both code from both code after decimal value appearing 16 digits. Where I have made mistake?

1532

kumaillakhani:

I have tried both code from both code after decimal value appearing 16 digits. Where I have made mistake?

This is not your fault, it's a feature of double type. NormalizeDouble() provides rounding (BTW in a slightly non standard way) to required number of decimal places. But double is still double.
It could be dangerous to normalize prices (stop loss and take profit are also prices) by NormalizeDouble() because not always a tick size is equal to points.
36617

Petr Nosek:
This is not your fault, it's a feature of double type. NormalizeDouble() provides rounding (BTW in a slightly non standard way) to required number of decimal places. But double is still double.
It could be dangerous to normalize prices (stop loss and take profit are also prices) by NormalizeDouble() because not always a tick size is equal to points.
Could you please provide a reference to the rounding standard(s) ? Thanks.
Moderator
7282

May be you should read this here: http://articles.mql4.com/866
Working with Doubles in MQL4
• www.mql5.com
The MQL programming opens new opportunities for the automated trading, many people all over the world already have appreciated it. When we are writing an Expert Advisor for trading, we must be sure that it will work correctly. Many newbies often have some questions when the results of some mathematical calculations differ from those expected...
1532

Alain Verleyen:
Could you please provide a reference to the rounding standard(s) ? Thanks.

appendix B.7 on page 43

36617

Petr Nosek:

appendix B.7 on page 43

Thanks Petr.

However what I wanted to point is there is no reason to think Metaquotes is following any standard if not documented, certainly not a US standard.

1532

Alain Verleyen:

Thanks Petr.

However what I wanted to point is there is no reason to think Metaquotes is following any standard if not documented, certainly not a US standard.

You're right that Metaquotes doesn't have to follow any standard (SI is not an US standard, but an international standard).
36617

Petr Nosek:
You're right that Metaquotes doesn't have to follow any standard (SI is not an US standard, but an international standard).

NIST is US, it's what I meant.

US like to think they are the "international standard". But it's not the place to discuss about that.