zero divide

 

Hi,

Not sure how to deal with math about ordersend lots, lotstep, minlot.... So I tried some, and suddenly an "zero divide" occured. By adding some debug "print", I'm sure it's because the math I just mentioned.

..... 
Print(ratio);  
Print("here   4");
double pudanlot = MathFloor( (beginposlot+secondposlot)/ratio/LotStep )*LotStep;
Print("here   5");

Running this code, I could see ratio=13.532, then see "here 4", then "zero divide".

Any idea?

 
joshatt:

Hi,

Not sure how to deal with math about ordersend lots, lotstep, minlot.... So I tried some, and suddenly an "zero divide" occured. By adding some debug "print", I'm sure it's because the math I just mentioned.

Running this code, I could see "here 4", then "zero divide".

Any idea?

Read this thread and learn from it: https://www.mql5.com/en/forum/147174
 

Then check the value of LotStep

 

Thanks a lot, RaptorUK and SDC.

The bug is "LotStep", which is defined before these lines, in a "if" block, so sometimes this block doesn't run.

Reason: