Need help to resolve "Zero Divide"

 

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

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);
}