How to resolve "Zero Divide"

Jun 06, 2014 at 07:42
470 Просмотры
5 Replies
Участник с May 02, 2012   14 комментариев
Jun 06, 2014 at 07:42
Hi guys,

Anyone able to advise on how to resolve this coding to avoid 'Zero Divide' error :-

double upbar_upwickvol=((High[a]-Close[a])/avgvol);
double upbar_lowerwickvol=((Open[a]-Low[a])/avgvol);
double upbar_realbodyvol=((Close[a]-Open[a])/avgvol);

Thanking you in advance for the kind assistance.

Best regards.
forex_trader_25447
Участник с Dec 21, 2010   131 комментариев
Jun 06, 2014 at 09:44
Make like this :

double upbar_upwickvol=0.0; // Here 0.0 can be ANY number !!!
double upbar_lowerwickvol=0.0;
double upbar_realbodyvol=0.0;

if ( avgvol!=0.0 )
{ upbar_upwickvol =((High[a]-Close[a])/avgvol);
  upbar_lowerwickvol=((Open[a]-Low[a])/avgvol);
  upbar_realbodyvol=((Close[a]-Open[a])/avgvol);
}
Mine pleasure.
TheCyclist
forex_trader_28881
Участник с Feb 07, 2011   724 комментариев
Jun 06, 2014 at 09:50
@StoneHeart

The High Close Open Low could also be 0, which means not enough history or the data for the pair is not there, iow's the pair is not on this broker.

So @EAcomparison

So open all the pairs you're trying to trade, and make sure you got enough data on the time frame you're trying to trade. Simply drag your charts back a bit.
Участник с May 02, 2012   14 комментариев
Jun 06, 2014 at 12:41
StoneHeart posted:
Make like this :

double upbar_upwickvol=0.0; // Here 0.0 can be ANY number !!!
double upbar_lowerwickvol=0.0;
double upbar_realbodyvol=0.0;

if ( avgvol!=0.0 )
{ upbar_upwickvol =((High[a]-Close[a])/avgvol);
  upbar_lowerwickvol=((Open[a]-Low[a])/avgvol);
  upbar_realbodyvol=((Close[a]-Open[a])/avgvol);
}
Mine pleasure.

STONEHEART, THANK YOU SO MUCH FOR YOUR SOLUTION & IT WORKS PERFECTLY !!!
Участник с May 02, 2012   14 комментариев
Jun 06, 2014 at 12:41
TheCyclist posted:
@StoneHeart

The High Close Open Low could also be 0, which means not enough history or the data for the pair is not there, iow's the pair is not on this broker.

So @EAcomparison

So open all the pairs you're trying to trade, and make sure you got enough data on the time frame you're trying to trade. Simply drag your charts back a bit.

TheCyclist, thanks for your advise :)
Участник с Jun 09, 2011   186 комментариев
Jun 18, 2014 at 07:33
Thanks for sharing Stone
http://www.freeforexrebates .info
You must be connected to Myfxbook in order to leave a comment
*Коммерческое использование и спам не допускаются и могут привести к аннулированию аккаунта.
Совет: Размещенные изображения или ссылки на Youtube автоматически вставляются в ваше сообщение!
Совет: введите знак @ для автоматического заполнения имени пользователя, участвующего в этом обсуждении.