Round down double mql5

 

Hello guys,

how can i round a double to lowest number?

I have issue for lotsize in martingale 1.5

Starting from 0.01 i have

0.01 * 1,5 = 0.015 (i want round down to 0.01)

 

Please take the time to search and read the documentation before posting ...

MathCeil

Returns integer numeric value closest from above

MathFloor

Returns integer numeric value closest from below

MathRound

Rounds of a value to the nearest integer

Documentation on MQL5: Math Functions
Documentation on MQL5: Math Functions
  • www.mql5.com
Math Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Hello,

thanks for reply but i saw this one and dont fit because Is for integer, i Need It for double

 
Mirco #: thanks for reply but i saw this one and dont fit because Is for integer, i Need It for double

It is basic maths ...

0.01 * MathFloor( 1.5 )
 

I dont need in this way, i do and example to be clear

Lotsize 0.01 martingale 1.5


With Mql4 i have this steps as default Round the double value

0.01

0.01

0.02

0.03

 I Need to have the same for mql5

 
Mirco #: I dont need in this way, i do and example to be clear.

Lotsize 0.01 martingale 1.5

With Mql4 i have this steps as default Round the double value

0.01, 0.01, 0.02, 0.03

 I Need to have the same for mql5

You have not explained anything clearly at all.

Besides, the function works exactly the same on both MQL4 and MQL5.

 
void OnStart() {
   double dbSeed  = 1.0,
          dbRatio = 1.5,
          dbStep  = 0.01;
   for( int i = 0; i < 10; i++ ) {
      PrintFormat( "Lots: %.2f (Value: %.6f)", MathFloor( dbSeed ) * dbStep, dbSeed );
      dbSeed *= dbRatio;
   };
};
Lots: 0.01 (Value: 1.000000)
Lots: 0.01 (Value: 1.500000)
Lots: 0.02 (Value: 2.250000)
Lots: 0.03 (Value: 3.375000)
Lots: 0.05 (Value: 5.062500)
Lots: 0.07 (Value: 7.593750)
Lots: 0.11 (Value: 11.390625)
Lots: 0.17 (Value: 17.085938)
Lots: 0.25 (Value: 25.628906)
Lots: 0.38 (Value: 38.443359)
Reason: