Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Improve your rating!
parksonchew
273
parksonchew 2014.06.06 09:24 

I suspected that when the value of H=C, O=L or C=O happen in the below equation, the "Zero Divide" error will trigger.

But how can I rectify the coding?

Anyone care to assist?

Thanks and appreciate much. 

 

double upbar_upwickvol=((High[a]-Close[a])/avgvol);
double upbar_lowerwickvol=((Open[a]-Low[a])/avgvol);
double upbar_realbodyvol=((Close[a]-Open[a])/avgvol);
qjol
3243
qjol 2014.06.06 10:30  
if (High[a]-Close[a] != 0.0)
   double upbar_upwickvol=((High[a]-Close[a])/avgvol);
d4v3
28
d4v3 2014.06.06 10:47  

You won't get a zero divide as long as avgvol is not 0.

If H-C is 0 then (H-C)/avgvol will be 0.

if (avgvol>0)
{double upbar_upwickvol=((High[a]-Close[a])/avgvol);
double upbar_lowerwickvol=((Open[a]-Low[a])/avgvol);
double upbar_realbodyvol=((Close[a]-Open[a])/avgvol);
}
/
To add comments, please log in or register