How to display e-notation/scientific doubles correctly

Hello ,
I’m making an Expert advisor including MACD
In the code I depend on the value of Signal and Main line ( Histogram) in MACD in the bar 0 and bar 1 .
it works perfect but sometime it comes out with strange values as -7.835123405921764e-05
, I print out those values so you can see in the attachments .

Signal >>> means the value of Signal line in bar 0
Main>> the value of Main line in bar 0
Signal Past >> the value of Signal line in bar 1
Main past >> the value of Main line in bar 1

I use variables for every entry in MACD

extern ENUM_TIMEFRAMES MACD_Timefr1 ; // Time Frame

extern int Fast_Ema1 = 12 ; // Fast EMA

extern int Slow_Ema1 = 26 ; // Slow EMA

extern int Signal_Period1 = 9 ; // Signal Period

extern ENUM_APPLIED_PRICE Applied_Price1 ; //Applied Price

iMACD(NULL, MACD_Timefr1, Fast_Ema1, Slow_Ema1, Signal_Period1, Applied_Price1, MODE_SIGNAL, 1)

Files:

5.png 60 kb

It is not a strange value. It is a perfectly normal value but expressed in scientific form/notation (E-notation) instead of general decimal form/notation.

-7.835123405921764e-05 is the same as -0.00007835123405921764

Yes , I just understand that , However I can’t get rid of that , I just want the normal value as I make equation with > , < and when one value is formed into e_notation but other one doesn’t MT mess everything

Internally the value is stored in a binary format called “double”, so internally in the calculations, equations or comparison ("<, >, <=, >="), it does not matter, because it works correctly!

But for outputting/printing, just use the DoubleToString() function to see normal general decimal format.

EDIT: Internally, there is no normal, nor scientific nor e-notation. That is just for us humans to read. So, MT is not “messing” it up. Your code is probably not done correctly and that is what is “messing” it up.

So show that part of your code so that we can correct it.

I will check that again maybe something wrong , thanks alot for your help

btw I used both DoubleToString and NormalizeDouble but it keeps showing in e-notation even if the rounding was just 5 numbers after the decimal

Don’t use NormalizeDouble() !!! See the following link: https://www.mql5.com/en/forum/146370#comment_3693988

Show the code where you are using DoubleToString() and show the results in the log file that you are getting!

Yes it was a little mistake in the code and fixed it
Thanks alot for your help :slight_smile:

You are welcome!..