Zero divide problem

 

Hi all, please go thru this articlea and help solve my problem.

I develop my own custom indicators with MQL4. And it seems allright. But when I check the Tab 'Experts' in Terminal. I find some error message. It says 'zero divide'. I have two questions as below:

1. if such error happened, why my indicator can still show the chart? Also according to my calculation, the result is right.

2. the error occured only in tow situation: 1. it is launched firstly 2. I change the security's timeframe

So how can I locate where generates such error? please gve me some advices? Tks.

 

Learn to use the Print() function.

Place in code areas which might only be executed on first launch eg, init()

Also identify code areas specifically using timeframe references.

.

You are looking for identifiers that have ZERO value and really... the first place to use Print() is where code does division!

Just print out division operands IF divisor == 0

 

Use a Print() statement before any division calculations to show all the denominator components.

Post the code if you want, and we'll have a look.


CB

 

I may be wrong, but I think I've seen divide by zero stop even the print that comes before the offense (don't ask me how that happens)

so. during debugging:

if(denominator == 0) { Print("It's gonna be a zero, Ralph...");denominator = 0.0000000001; }

result = something/denominator;