So I have found the issue of what is causing zero divide - I have not seen this before until now. I thought I was finished with my code until this popped up! I have 3 variations of my EA. 1 works flawlessly, the other two are similar in this department (code below). I cannot understand why this would be causing zero divide?
Look for the lines with the Arrows indicating the lines that are causing problem... I have isolated it to being this problem here? Either that or I am getting an anomaly with AUDUSD backtest (I download my historical data from Forex Tester 2... seems to work with one of my EA's fine.)
I'm not sure you have found the issue . . . how do you know you have ?
I don't think the code you have arrowed will cause a divide by zero error, to be certain replace this . . .
if(ema21 - H1_low > Point / 2) // << These parts here?
with this . . .
double HalfAPoint = Point / 2.0; if(ema21 - H1_low > HalfAPoint)
and try again.
I suspect your error will remain as it is located somewhere else . . .
I can only locate one /division problem above.
The zero divide isn't coming from the above function.
If you don't want to show all the codes then:
Track down all your division problems within ea, custom_indicators and included files.
Make sure the expression on right_side of / cannot equal 0.
Added:
On another note, you could really benefit from ArraySort().
If you wanna know if Daily_3 is highest/lowest, make array and sort.
I'm not sure you have found the issue . . . how do you know you have ?
I don't think the code you have arrowed will cause a divide by zero error, to be certain replace this . . .
with this . . .
and try again.
I suspect your error will remain as it is located somewhere else . . .
I have "V1-V2-V3" of my EA.
I essentially copied over V1 to a new blank template and changed the part I illustrated above over to (below code) and it gave me a zero divide error during a back-test on AUDUSD. Does the data have anything to do with zero divide? When I run a back-test of all the version of my EA on EURUSD from 2001-2013 (Forex Tester downloaded data and imported in ST), I do not get any errors on any one of my EA's?
PullBack_Bar = Time[1]; // << These parts here? } if(PullBack_Bar > triggerBarTime) // << These parts here? { H1_Buy_Touch = "H1 Buy Touch"; OrderEntry(0); // Pending order Buy Stop function is called. }
Im just running through other pairs and this zero divide problem doesn't seem to be showing up unless its on AUDUSD with V2 and V3? Correct me if the data has nothing to do with it?
I have "V1-V2-V3" of my EA.
I essentially copied over V1 to a new blank template and changed the part I illustrated above over to (below code) and it gave me a zero divide error during a back-test on AUDUSD. Does the data have anything to do with zero divide? When I run a back-test of all the version of my EA on EURUSD from 2001-2013 (Forex Tester downloaded data and imported in ST), I do not get any errors on any one of my EA's?
There are no mind readers here. You haven't shown us the code with the divide, so no one here can help you.
All I asked was a simple question, does the data have anything to do with it? If not then I understand more about zero divide from people who have experience with it... Didn't think there were mind readers here...
There is too much code to post every little divide in here. As far as I was concerned I thought I isolated the issue to what I explained above, but apparently not. It's just a little weird how I change one tiny thing and then it doesn't work because I get zero divide (the little thing I changed is what I illustrated in the first post.)
@RaptorUK so essentially it could be an anomaly in the price of the data during my back-test, in which case, on the AUDUSD. Just a little weird that V2 and V3 run about 1/4 of the way through flawlessly and then it all of a sudden hits a zero divide and stops the EA from working all together.
@RaptorUK so essentially it could be an anomaly in the price of the data during my back-test, in which case, on the AUDUSD. Just a little weird that V2 and V3 run about 1/4 of the way through flawlessly and then it all of a sudden hits a zero divide and stops the EA from working all together.
If you want to spend days sorting this simple issue then by all means feel free . . . . I wouldn't.
If you know when it happens during your back test then it's easy to find . . . start the back test a day before the date when it happens . . . find out exactly, to the minute, when it is going to happen . . . for all the divisions in your code . . . yes, all of them, add a Print() before the line containing the division which prints the divisor and a reference to the line of code in question . . .
For example:
if(d == 0.0) Print("a = c / d - divisor d is " + d ); a = c / d;
When your code terminates with the divide by zero error check the log file and in the last few prints will be the print showing the line of code that produced the error and which variable was set to zero . . .
. . . learn to work smarter and hunt your issues down logically and efficiently.
Hey, you're right, sorry for being vague!
And you don't learn - You've been repeatedly asked for ALL the (relevant) code and your variable values. Why are we still having to ask 21 posts later? Put the print statements in your code and get some information like what and were.
Then if you still can't fix your problem, ask.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
So I have found the issue of what is causing zero divide - I have not seen this before until now. I thought I was finished with my code until this popped up! I have 3 variations of my EA. 1 works flawlessly, the other two are similar in this department (code below). I cannot understand why this would be causing zero divide?
Look for the lines with the Arrows indicating the lines that are causing problem... I have isolated it to being this problem here? Either that or I am getting an anomaly with AUDUSD backtest (I download my historical data from Forex Tester 2... seems to work with one of my EA's fine.)