
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
Double-precision floating-point format - Wikipedia, the free encyclopedia
See also The == operand. - MQL4 programming forum
MT4:NormalizeDouble - MQL5 programming forum
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum
Hi Guys, great help from every input, But I'm new to programming and the Normalize double function does not gives consistent output even though used correctly and so I was looking for alternative to Normalize the values of indicator result like RSI, iBands, etc?
I know there are solutions mentioned above and in other forums but, those don't apply because I need this value to be further used for calculations in my code. So, I cannot use DoubletoString, and don't really know what I need to do as I just want to limit the digits to 4 decimals for any values.
For e.g: My code:
Output:
Here, how do I get RSI to 5 digits without using NormalizeDouble?
Appreciate any help and Thanks for reading :)
Improperly formatted code edited by moderator.
Appreciate any help and Thanks for reading :)
EDIT: I misread you post. Please read my answer at post #19 further below ...
When outputting values as strings, use the DoubleToString function.
Also, please use the CODE button (Alt-S) when inserting code.
Since the RSI always has 2 decimals, I used this:
If you select "Digits," you will be taking the decimals from the symbol on the chart or the one you have selected in the tester. That's why in the normalized example you showed, I deduce that you used a 5-decimal forex pair.
It's only MetaQuotes rendition of the Indicator that limits the display to two digits, but internally it has more.
RSI is based on an exponential moving average which has been scaled to be between 0 and 100, but at no point is it restricted to only 2 digits in its equation.
It would be better to say that it is the universal interpretation, since in ALL trading platforms it is ALWAYS 2 decimals (it is not exclusive to MetaQuotes).
Obviously I know how the RSI is constructed and that there can be tens of decimals, but I speak for practical purposes based on what we all know and the OP asked for (4 digits, i.e. 00.00 as any platform shows).
In any case the OP wanted to "normalize" to 2 decimals and I have already shown how ....NO using "Digits".
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.
1.- I said trading platform. Not a spreadsheet based study.
2.- Correct, the OP asked for 4 decimals (I understood digits). It simply has to change the 2 to a 4. Valid whether you use NormalizeDouble or DoubleToString.