I have this code in my indicator and I would like to get rounds the floating point values to the six digits for example -0.000092 as it is the value of the MACD indicator. The issue is that I get -0.0001. Could you help me how to fix this ?
Alert("mMACD = ",mMACD," mMACDSignal = ",mMACDSignal);
Use the new "DoubleToString" function to convert the Double into a String of the precision you require (see example below).
Alert( "mMACD = ", DoubleToString( mMACD, Digits ), " mMACDSignal = ", DoubleToString( mMACDSignal, Digits ) );
This function was previously denoted as "DoubleToStr" in the previous builds, but use the new version for forward compatibility.
MQL5 Reference: https://www.mql5.com/en/docs/convert/doubletostring
Old MQL4 Reference: https://docs.mql4.com/convert/DoubleToStr
To add comments, please log in or register