Download MetaTrader 5

MathRound and MathCeil not rounding double var

To add comments, please log in or register

Hi folks,


I'm implementing a function to calculate volume to trade according to a fix  percentage of potential loss in comparison to total equity.

My problem is that im getting invalid volume since it have a lot of digits. I already tried using Mathround and mathceil/floor and it keep with a lot of digits.

Before rounding functions



After function has passed:

After. No changes 


Any ideas?


thanks in advance ! :) 

Alexey Da
Alexey Da  

At first function MathCeil() doesn't change argument value (argument is passing by value). To get result is returned by MathCeil() you should use statement like this:

(please read help topic


Finally why don't you use function NormalizeDouble()? 

Documentation on MQL5: Math Functions / MathCeil
Math Functions / MathCeil - Documentation on MQL5
To add comments, please log in or register