Why not use Print() to ascertain the values of bbUpper and bbLower directly before you attempt to set PercentB...
And take it from there.
CB
nondisclosure:
It looks from your code as though it has to be because the upper and lower bands are the same (i.e. bbUpper-bbLower equals zero), including the special case where both values returned by iBands() are zero.It must be late and I can't find it. It's in an indicator, that when loaded on a chart, it works fine. But when I call it from an EA I get Zero Divide. note: I have called this from 9 other EA's. Each call gives me the same result in the Journal for Strategy Tester.
I've not checked this but, if you have something like 87354 bars of history, then calling iBands() with a shift value such as 87352 may well give the same value for the upper and lower bands (because the standard deviation cannot be calculated over fewer than 2 bars). If I were you I'd simply check for bbUpper == bbLower, and use a different calculation for PercentB[] if true.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It must be late and I can't find it. It's in an indicator, that when loaded on a chart, it works fine. But when I call it from an EA I get Zero Divide. note: I have called this from 9 other EA's. Each call gives me the same result in the Journal for Strategy Tester.
Here's the code call in the EA:
Here is the indicator code:I put a comment in my EA's (I've tested on multiple EA's) to see what the value was I was getting back. I get back the value the indicator shows in the chart window.
Any ideas?
Note: I get this error in the Strategy Tester.