EA crash zero divide by money management
-
Hello, I seem to get a ea crash on zero divide. On mq4 debug it points me to this line: else if (mode=="balanceRisk") {size=((value/100)AccountBalance())/(sl((TickValue/ticksize)*point)*PipValue(symbol));}
�
I am using build100 of the standalone exe version.Thank you!
-
Hmmm seems to be caused by a SL of 0, but why is it 0.
It’s a duplicate bug of https://fxdreema.com/forum/topic/4871/zero-divide-error-and-risk-of-balance-volume-size-depending-on-stop-loss/5
-
This MM requires SL to be different than 0, because the lot size is calculated from SL. How can I fix this problem?

-
Hello! Thanks for your reply. I could get rid of the problem, by switching from Price Level to Price Fraction and then adding some buffer (e.g. spread or a factor*ATR). Originally, I tried to follow a MA as base curve and then add an offset, but the problem was when the price was running away quickly from the MA, causing the SL (in price level) to be on the wrong side, creating 0, resulting in a crash. With doing price fraction and then adding it to the open-price and adding up a bunch of small factors, the whole calculation ended up being way more robust.
The crash is actually not a too bad thing, on multiple times testing it sometimes didn’t crash and then somehow opened many tiny trades, resulting in a way too big risk.
Also tried Miror’s fix, but this seeme to resulted in trades without a SL at all, which was way too risky.So all good, no real money lost.
Fix => avoiding price-levels and using fractions or pips instead for SL/TP
Thank you!
