abstract_mind:
NICE !!!I've tried your function trend_watch() and did not catch any divide by zero error. Perhaps the issue is inside tail() function, which you may post.
It seems that you nailed the problem spot on . I missed that call to tail(), and when I checked it, sure enough I found a possibility to divide by zero when the size of the candle's body is zero (open price = close price).
I fixed that problem and now all we have to do is to wait and see that 'zero devide' doesn't happen anymore.
/*------------+ | tail sizer | +-------------+ This routine size up the requested candle's tail */ double tail (int timeframe, int shift) { int type; double open=iOpen(Symbol(),timeframe,shift), close=iClose(Symbol(),timeframe,shift), high=iHigh(Symbol(),timeframe,shift), low=iLow(Symbol(),timeframe,shift); double result, upper_body,lower_body, tail, body=MathAbs(open-close); if (open<close) // if it is a green candle { type=1; upper_body=close; lower_body=open; } else { type=-1; upper_body=open; lower_body=close; } double upper_tail=high-upper_body; double lower_tail=lower_body-low; // tail= MathMax(upper_tail,lower_tail); tail= MathMax(upper_tail,lower_tail); if (upper_tail>lower_tail) tail=-tail; if (body==0) result=9999999; // the actual result should be infinite else result=(tail/body)*100; // in precent /* Alpha_TF=StringTrimLeft(StringSubstr(comment,StringFind(comment," ",3),0)); if (Alpha_TF=="M5") timeframe=5; if (Alpha_TF=="M15") timeframe=15; if (Alpha_TF=="M30") timeframe=30; if (Alpha_TF=="H1") timeframe=60; if (Alpha_TF=="H4") timeframe=240; if (Alpha_TF=="D1") timeframe=1440; if (Alpha_TF=="W1") timeframe=10080; if (Alpha_TF=="MN") timeframe=43200 ; */ return (result); }
Thank you,
James
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
Greeting,
Sometimes, I get a 'zero devide' error while running my EA.
I've narrowed the possibility and found out that when I disable a routine called trend_watch( ),
the 'zero devide' doesn't happen anymore.
I looked into that routine thoroughly but couldn't see anything that might cause deviation by zero.
I'll be glad if someone of you knowledgeable people would be kind enough to look at it,
and tell what might be the problem with this routine that cases this 'zero devide' error.
Thank you,
James