MathRound and MathCeil not rounding double var

 

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 ! :) 

 

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:

tmp=MathCeil(tmp);
(please read help topic https://www.mql5.com/en/docs/math/mathceil)

 

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

Documentation on MQL5: Math Functions / MathCeil
  • www.mql5.com
Math Functions / MathCeil - Documentation on MQL5