Hi there,
Is there anyway to round 0.001 to 0.01?
Eg : 0.012 to 0.02.
I tried round ();
Unfortunately it only round up 5 and above.
Thanks in advance.
Hi and good morning,
in my opinion there is no MQL function for your requirement. But you can
use MathCeil() for that. E.g. (for 2 digits):
value = MathCeil(value * 100.0) / 100.0;
Best regards
Lee Su Keat: Is there anyway to round 0.001 to 0.01? Eg : 0.012 to 0.02. I tried round (); Unfortunately it only round up 5 and above.
Yes, use ceil() / MathCeil(). There is round(), floor() and ceil(). It helps to read the documentation ... https://www.mql5.com/en/docs/math
Example:
double dblValue = 0.012, dblCeiling = ceil( dblValue / 0.01 ) * 0.01; PrintFormat("Value = %f; Ceilling = %f", dblValue, dblCeiling);
2021.07.17 07:58:16.757 Test EURUSD,H1: Value = 0.012000; Ceilling = 0.020000
Documentation on MQL5: Math Functions / MathCeil
- www.mql5.com
MathCeil - Math Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Werner Klehr:
Hi and good morning,
in my opinion there is no MQL function for your requirement. But you can
use MathCeil() for that. E.g. (for 2 digits):
Best regards
Fernando Carreiro:
Yes, use ceil() / MathCeil(). There is round(), floor() and ceil(). It helps to read the documentation ... https://www.mql5.com/en/docs/math
Example:
Thank you. ceil() is works.
William Roeder:
See also
MT4:NormalizeDouble - General - MQL5 programming forum #3.3 2017.01.04
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum #2 2017.05.19
See also
MT4:NormalizeDouble - General - MQL5 programming forum #3.3 2017.01.04
How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum #2 2017.05.19
Thanks.
Have a good weekend. =D
Lee Su Keat: Thank you. ceil() is works. Thanks. Have a good weekend. =D
You are welcome!
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