[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Divide by Zero Error



PureBytes Links

Trading Reference Links


I get this error on the one minute S&P but not on the 5 minute bonds. Can
anybody be kind enough to fix this indicator so its fits all.

Thanks,

Robert



Input:  OVERBOUGHT(45), OVERSOLD(-45),REI_BARS(5);

Var:Cond1(0), Cond2(0), D1(0), SumD(0), Cnt(0), REI(0);

If (H<L[5] and H<L[6]) and (H[2] < C[7] and H[2] < C[8]) then Cond1=0 Else
Cond1=1;

If (L>H[5] and L>H[6]) and (L[2] > C[7] and L[2] > C[8]) then Cond2=0 Else
Cond2=1;

If Cond1=1 and Cond2=1 then D1=(H-H[2])+(L-L[2]) else D1=0;

SumD=0;

For cnt =0 to REI_BARS-1 begin
 SumD=SumD+D1[cnt];
End;

REI = (100/REI_BARS)*SumD/(Highest(H,REI_BARS) - Lowest(L,REI_BARS));

Plot1(REI,"TDC.REI");
Plot2(OVERBGHT,"OverBght");
Plot3(OVERSOLD,"OverSold");