zero divide in '8320-30394.mq4' (12065,31) THIS ERROR CODE MAKES MY EA STOP
-
Does anyone have experience with the mt4 FAULT codes.
I've created a pretty successful ea only now getting this fault code after no more action from the ea.
can someone help resolve it? -
@serioza It is a problem with the SL position. The Ea is looking for a SL that is not there. Can you please share the link to the project?
-
not sure how to share a link to the project
-
Another fault is ( uninit reason 3 ) dont know what that means, it used to work fine but somehow have a feeling the broker is blocking something on its end as manual orders don't go through either with enough margin
-
The best is to open the source code and look what's in that line 12065. Normally these zero-divide errors happen when one of those Risk % MM methods are used, but those who depend on SL. Or, sometimes when the symbol doesn't provide data, for example when trying to backtest multiple symbols, which is not possible in MT4.
Uninit reason 3 seems to be Symbol or chart period has been changed. So I don't know, maybe it's possible that something wrong happens if you are changing timeframes. Do you get this error when you are changing timeframes?
I don't know if the EA you are working on is the one that is currently active. But I checked what's in line 12065 and there is an expected division right there:
double PipValue(string symbol) { if (symbol == "") symbol = Symbol(); return CustomPoint(symbol) / SymbolInfoDouble(symbol, SYMBOL_POINT); }Value of 0 is probably SYMBOL_POINT of the symbol. So... which is the symbol and is everything fine with it? This "point" number should always be different than 0, I believe.
-
@fxdreema hm no the uninit appears only when I change the timeframe hope it doesn't affect anything else, the zero divide fault code appears when a SL should be placed but is rejected somehow, it's also in the journal.
2021.12.28 19:08:32.778 '': modify order #56840184 buy 0.01 SPX500 at 4805.39 sl: 0.00 tp: 0.00 -> sl: 4631.00 tp: 0.00
2021.12.28 19:08:32.895 ''': order #56840184 buy 0.01 SPX500 at 4805.39 was modified -> sl: 4631.00 tp: 0.00
2021.12.28 19:08:34.528 ''': modify order #56840184 buy 0.01 SPX500 at 4805.39 sl: 4631.00 tp: 0.00 -> sl: 0.00 tp: 0.00
2021.12.28 19:08:34.727 ''': order #56840184 buy 0.01 SPX500 at 4805.39 was modified -> sl: 0.00 tp: 0.002021.12.28 17:10:12.280 '***** SPX500,Daily: zero divide in '8320-37707.mq4' (12065,31)
After it stops working, in tester it's a critical error
2021.12.28 17:07:49.290 SPX500,M1: 137276 tick events (13521 bars, 1555327 bar states) processed in 0:00:01.984 (total time 0:00:02.125)
2021.12.28 17:07:49.290 2021.03.18 20:01:06 Tester: order #1 is closed
2021.12.28 17:07:49.290 2021.03.18 20:01:06 Testing pass stopped due to a critical error in the EA
2021.12.28 17:07:49.290 2021.03.18 20:01:06 ***** SPX500,M1: zero divide in '8320-37707.mq4' (12065,31)
2021.12.28 17:07:49.290 2021.03.18 20:01:06 ***** SPX500,M1: open #2 sell stop 0.01 SPX500 at 3871.57 ok
2021.12.28 17:07:49.290 2021.03.18 20:01:06 ***** SPX500,M1: open #1 buy 0.01 SPX500 at 3919.98 ok -
@fxdreema how to tell in which block is this error?
-
Looks like I've found the problem, I've replaced in the (if trade) block the specified symbol by completely deleting the symbol definition and retyping it
-
@serioza said in zero divide in '8320-30394.mq4' (12065,31) THIS ERROR CODE MAKES MY EA STOP:
@fxdreema how to tell in which block is this error?
Just look few rows above if there is a comment that says the number of the block. But don't look at the name of the class, because it has other number that is used in the code only.
But if the error is somewhere in the many functions outside the blocks, you will not be able to tell which is the block.
-
@serioza What do you mean deleting the symbol definition and retyping it? I know this is an old topic but can you explain more or provide a screenshot ? Thank you!!
-
For those who still have the issue - there is something I realized: As this app runs in the cloud, sometime there might be hickups... like the connection is not stable enough and so on... this could lead to issues whilst the creation of some blocks. I had the same zero-divide issue and therefore I re-created the buy and sell blocks, afterwards they worked as supposed. of course the SL cannot be 0, but I was looking for the lowest or highes candle of 10 after an EMA cross, hence I knew that the SL was never 0. It could also have been an issue with the highest/lowest function, that provided maybe a 0 as SL - but this function was also part of the buy / sell block. So again, I deleted them and re-created them, and all of a sudded the EA worked as supposed - no zero-divide anymore. No functionallity was changed... sometimes that happens - was not the first time that it took me hours to find an issues and the last solutions was to re-create the block, just to find that it could have worked just fine. I blame it on the connections losses that appear sometimes and I make mayself aware of the blocks that I was creating during that time. ... maybe that solves your issues as well.
-
Alternatively, you could also store the SL value into a variable and have an if condition when SL != 0, then execute orders. This way, SL will always be something other than 0 in order to execute orders.