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
Now that I read your post again, I now see that you don't want to use DoubleToString.
However, you can not limit a floating point to only 4 digits, because floating point numbers are not decimal. They are binary.
Thank you very much for your prompt response. Yes, because I need this value further in my code to do more calculations, I cannot convert it to string.
I was wondering if I can't limit the digits to 4, is there some kind of function I can call to get the value with 4 digits, or any other solution/calculation that will allow me to get my desired value?
Appreciate any help and Thanks for reading :)
I find it ridiculous that you want to use 4 decimal places. In practice (unless you want to do HFT) decimals are worthless in the case of RSI. If 2 is already too many... 4 is a fantasy.
I find it ridiculous that you want to use 4 decimal places. In practice (unless you want to do HFT) decimals are worthless in the case of RSI. If 2 is already too many... 4 is a fantasy.
Thank you for your prompt response. Yes, I agree 2 digits are enough to get RSI value, but I need this solution for many other functions/calculations in my code, hence I cannot convert it to string & was wondering if there's some kind of function I can call to get the value with 4 digits, or any other solution/calculation that will allow me to get my desired value?
Appreciate any help and Thanks for reading :)
As already explained, floating point numbers are represented in binary form, not in decimal form. It is impossible to limit the number of "decimal" digits internally.
All you can do is approximate it, which is what NormaliseDouble already does, but you can never get to an exact decimal place because it is binary, not decimal.
Thank you for your prompt response. Yes, I agree 2 digits are enough to get RSI value, but I need this solution for many other functions/calculations in my code, hence I cannot convert it to string & was wondering if there's some kind of function I can call to get the value with 4 digits, or any other solution/calculation that will allow me to get my desired value?
Appreciate any help and Thanks for reading :)
Where before you put a "Digits", now simply put the number of decimals (4).
As already explained, floating point numbers are represented in binary form, not in decimal form. It is impossible to limit the number of "decimal" digits internally.
All you can do is approximate it, which is what NormaliseDouble already does, but you can never get to an exact decimal place because it is binary, not decimal.
Where before you put a "Digits", now simply put the number of decimals (4).
What do you mean, sometimes it doesn't work? Please argue that.
It works perfectly. Please read carefully what I said above.
https://www.mql5.com/en/forum/135572/page2#comment_47926093
What do you mean, sometimes it doesn't work? Please argue that.
It works perfectly. Please read carefully what I said above.
https://www.mql5.com/en/forum/135572/page2#comment_47926093
So, Here's a part of My Code that is perfectly correct (or at least what I've been thinking) but still get this wired output(attached) with NormalizeDouble
Code
Any Help to why would be appreciated, Thanks
Below is my simple code to get MA values. Now the output I get is different value on different candles using NormalizeDouble Function, even though I haven't changed the code, but just the shift value to get the value of different candles. The value displayed by NormalizedDouble Function is not consistent. Even if I use Digits or put the number 4 manually in my code.
I've attached the Output of my code as well.
This is what I was referring when I said that the Normalize double function is not working sometimes.