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

Re: EL Divide by zero error



PureBytes Links

Trading Reference Links

> If I have the Mult set to 1.2 it works, if I optimize say from .5
> to 1.2 I get the dividing by  zero error 

You get the divide by zero if your profits fall too low:

> Conts    = Floor((NetProfit+1)/ContSize) + 1;
> RunningCapital = Capital + NetProfit;
> MaxPntRsk   = ((LossPcnt/100)*RunningCapital)/BigPointValue;
> Max_Loss  = Ceiling(MaxPntRsk/Conts);

When NetProfit+1 goes negative, Conts is zero, and the Max_Loss 
calculation blows up.

Instead of calculating Conts as Floor(x/y)+1, maybe instead you 
should use

  Conts = MaxList(1, Floor((NetProfit+1)/ContSize));

That way Conts is always positive.

Gary