NormalizeDouble found bug - or Ask or Digits / MarketInfo problem ?

 

Hello, first of all i have trouble to post on mq4 forum so i write here ... should be same anyways i found a bug.

 

(Test 1) 

double blue_0 = NormalizeDouble(iMA(NULL, 60, 5, 0, MODE_LWMA, PRICE_CLOSE, 0), Digits);

Print("first:",NormalizeDouble(blue_0 +(10 * Point), (int)MarketInfo(NULL, MODE_DIGITS)));

Print("sec",NormalizeDouble(Ask, (int)MarketInfo(NULL, MODE_DIGITS)));

 

(Test 2)

 double blue_0 = NormalizeDouble(iMA(NULL, 60, 5, 0, MODE_LWMA, PRICE_CLOSE, 0), Digits);

Print("first:",NormalizeDouble(blue_0 +(10 * Point), Digits));

Print("sec",NormalizeDouble(Ask, Digits));

 

here is the problem boys : http://oi65.tinypic.com/301ocox.jpg

somehow it gives abnormal digits from time to time ... happens not often but on many pairs you see it when u look for a minute on the expert window.

can anyone tell me how is that possible ? is it the Digits bugged or MarketInfo or Ask or iMA gives wrong digits ?

i hope someone can clear me out. a direct developer would be appreciated. 

Image - TinyPic - Free Image Hosting, Photo Sharing & Video Hosting
  • tinypic.com
Tinypic™ is a photo and video sharing service that allows you to easily upload, link and share your images and videos on MySpace®, eBay®, blogs and message boards. No account required, upload your photos and videos today!
 

Please note that when output to Journal using the Print() function, a normalized number may contain a greater number of decimal places than you expect. For example, for:

   double a=76.671;             // A normalized number with three decimal places
   Print("Print(76.671)=",a);   // Output as is
   Print("DoubleToString(a,8)=",DoubleToString(a,8)); // Output with a preset accuracy

you will have the following in the terminal:

 DoubleToString(a,8)=76.67100000

 Print(76.671)=76.67100000000001


https://www.mql5.com/en/docs/convert/normalizedouble

Documentation on MQL5: Conversion Functions / NormalizeDouble
Documentation on MQL5: Conversion Functions / NormalizeDouble
  • www.mql5.com
Conversion Functions / NormalizeDouble - Reference on algorithmic/automated trading language for MetaTrader 5
 
Marco vd Heijden:

Please note that when output to Journal using the Print() function, a normalized number may contain a greater number of decimal places than you expect. For example, for:

   double a=76.671;             // A normalized number with three decimal places
   Print("Print(76.671)=",a);   // Output as is
   Print("DoubleToString(a,8)=",DoubleToString(a,8)); // Output with a preset accuracy

you will have the following in the terminal:

 DoubleToString(a,8)=76.67100000

 Print(76.671)=76.67100000000001


https://www.mql5.com/en/docs/convert/normalizedouble

i dont understand that means the double itself is correct just the "Print" function display more digits because it is converted to a string ? ...
 

Hi.

check this post. I had the same problem.

https://www.mql5.com/en/forum/65621

You can fix it by using this method:

DoubleToString(NormalizeDouble(dYourVariable,2), 2);

Strange behaviour of the NormalizeDouble() function.
Strange behaviour of the NormalizeDouble() function.
  • www.mql5.com
I use some notification alerts in my EA for displaying variables.
 
In all cases that's not a bug.