THIS EATING MY HEAD BIG TIME !!!
Look at the log or experts tab . . . .
2013.11.04 09:55:05 malfunc_tester EURUSD,H1: zero divide
2013.11.04 09:55:05 malfunc_tester EURUSD,H1: zero divide
2013.11.04 09:55:04 malfunc_tester EURUSD,H1: zero divide
2013.11.04 09:55:04 malfunc_tester EURUSD,H1: zero divide
2013.11.04 09:55:03 malfunc_tester EURUSD,H1: zero divide
2013.11.04 09:55:03 malfunc_tester EURUSD,H1: zero divide
2013.11.04 09:55:01 malfunc_tester EURUSD,H1: zero divide
2013.11.04 09:55:01 malfunc_tester EURUSD,H1: zero divide
Look at the log or experts tab . . . .
Make this simple change . . .
// Custom function PercCalc double PercCalc(string aSymbol,double pValue) { if(pValue == 0.0) // avoid divide by zero error return(0.0); double calc1=MarketInfo(aSymbol,MODE_BID)-pValue; double calc2=calc1/pValue; double calc3=NormalizeDouble(calc2*100,Digits); return(calc3); }
Look at the log or experts tab . . . .
Yes you are right raptor i tried replacing pValue with 2 in the divide and it displayed some red numbers. But why is this happening causing pValue to be 0?
Yes you are right raptor i tried replacing pValue with 2 in the divide and it displayed some red numbers. But why is this happening causing pValue to be 0?
Make this simple change . . .
Yer that now works. Thanks.
Add this to
EURUSDprev=MarketInfo("EURUSD",MODE_BID);
init()
Add this to
init()
It now works. EURUSDprev's work is to store the last Bid for use in the next tick so it has to be after the calculations so that only the previous Bid is used. But i think your method could also work only that if you are dealing with over 50 pairs it becomes lots of extra work unlike raptor style. I knew at start EURUSDprev wont have a value but i didnt know it would now stick there. I thought at the second tick it will now get a value and continue normally.
I know this topic is closed ... but just wanted to post this tip for the future readers.
If you are getting "zero divide" error in expert log then do the following:
1. Open mq4 file in editor
2. Search for "/"
3. Confirm the denominator is not zero (for manually entered using extern etc) .... or if the denominator is a calculated value then make sure that this is normalized
4. after normalizing the denominator, 99% chance is there that zero divide error would have gone.
4. You can normalize any value with following function
NormalizeDouble(variable, digit);
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I need help here. The label/object is not showing. After tests i discovered that its the division in the PercCalc custom function because if i comment out calc2 and calc3 then set calc1 as output like below it displays something please help;
Why is the division in PercCalc function causing a mulfunction?