I don't see the sign of a variable as a function in the docs. I would like to request this feature/function. This can already be achieved using if statements and sped up using branchless techniques but it would be nice to have a super fast simple function that returns 1 for positive, 0 for 0, and -1 for negative.
- help with ordersend description
- Feature request: Functions that return datetime of market open/close
- Useful features from KimIV
double MathSign(const double value) { return (value > 0) - (value < 0); }

Math Utils
- www.mql5.com
Handy functions for comparison, rounding, formatting and debugging of doubles (prices, lots and money).
I would make it a template so it works with any (comparable) datatype.
template <typename T> T MathSign(T value){ return (value > 0) - (value < 0); }

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