Download MetaTrader 5

Need help to resolve "Zero Divide"

To add comments, please log in or register
parksonchew
275
parksonchew  

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  
if (High[a]-Close[a] != 0.0)
   double upbar_upwickvol=((High[a]-Close[a])/avgvol);
d4v3
35
d4v3  

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