
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Wrong! To change the number of digits in the Data windows for Inidcator Output, you have to specifically tell the Indicator the number of digits to display! You can't just use rounding or normalising. The correct solution is something like this (as mentioned in post #3):
Hey fernando,
your solution seems exactly what i'm looking for. I want to trim the 9 decimals showing in the window to 3 decimals. i tried :
but i'm getting a "0.0" value showing in my screen...appreciate if you can point out what i'm doing wrong? thanks man.
Please read the documentation. That is not the way to use the "IndicatorSetInteger" function. That function is used to set properties of an indicator, not to adjust the digits of a variable.
ID
Description
Property type
INDICATOR_DIGITS
Accuracy of drawing of indicator values
int
Please read the documentation. That is not the way to use the "IndicatorSetInteger" function. That function is used to set properties of an indicator, not to adjust the digits of a variable.
ID
Description
Property type
INDICATOR_DIGITS
Accuracy of drawing of indicator values
int
appreciate your quick reply ferds,
i read the documentation and from how i understand, i simply add the following under OnInit as shown below :
i just wanted to show 3-decimal values printed on my screen but the above doesnt seem to be working too as you can see the 9 decimals in my screenshot below.
btw, i'm not trying to make any custom indicator (still newbie) but only trying to "print-variable-to-screen" with a simple comment line like so below :
btw, NormalizeDouble doesnt work either. The screen values actually kept on jumping up and down from the NormalizeDouble 3-decimals and then back again to the one you see above. It's very hard to read.
btw, NormalizeDouble doesnt work either. The screen values actually kept on jumping up and down from the NormalizeDouble 3-decimals and then back again to the one you see above. It's very hard to read.
Read the documentation for NormalizeDouble, in particular
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
build 3194: string() function bug was fixed as I recommended.
Read the documentation for NormalizeDouble, in particular
a ZILLION thanks Keith!
it worked beautifully!
I use NormalizeDouble() quite often.
https://www.mql5.com/en/docs/convert/normalizedouble
Example:
The output looks like this:
As with most thing in life, there is more than one way to accomplish the desired results.
in Indicator Data window,the numbers (after dot) show bunch of zeroes:
i need to be shown there only 2 decimals after dot.
used this function, but still doesnt help, there are still ZEROes shown...
double RoundNumber(double number, int digits) { number = MathRound(number * MathPow(10, digits)); return (number * MathPow(10, -digits)); }
Old post I know, but just to contribute and because I didn't see around this solution, I use
always workingYou solution is invalid for the question you quoted, and the answer has already been provided multiple times in post #1, #3, #11 and #52.
Please pay attention to the question and the answers already given.
in Indicator Data window,the numbers (after dot) show bunch of zeroes:
i need to be shown there only 2 decimals after dot.
used this function, but still doesnt help, there are still ZEROes shown...
double RoundNumber(double number, int digits) { number = MathRound(number * MathPow(10, digits)); return (number * MathPow(10, -digits)); }
dayTrend & hourTrend are instances of double
string commentData = StringFormat("DayTrend=%5.2f HourTrend=%5.2f", dayTrend, hourTrend);