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

Re: EL Divide by zero error



PureBytes Links

Trading Reference Links


I'm a little too foggy this morning to be a big help and it's difficult to
debug out of context, but just briefly:

Trying to debug the way you are describing may not be the most efficient
method. You only have three lines of code with a division in them.

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

One at a time, comment out the calculation and replace it with a reasonable
constant. Run your code with no other changes. Should be pretty easy to
find the errant line. Then, it will be easy to see where one of your values
become 0. Or, another easy debugging tool, send a print line to the debug
log that outputs the date, barnumber and current values of each of your
divisors. Look for a zero in the output when you run your code. Looking at
that will also let you know where there's a balliwick in the works.

If you still can't find the error using those two methods, write back. Hope
this helps!




                                                                                              
                    "Mel"                                                                     
                    <melsmail@xxx        To:     "omega-list" <omega-list@xxxxxxxxxx>         
                    pond.com>            cc:                                                  
                                         Subject:     EL Divide by zero error                 
                    02/17/2001                                                                
                    05:18 AM                                                                  
                                                                                              
                                                                                              




I really need help here, am testing the below code

I had several other conditions in the code  but as I was getting errors I
deleted most of them to try and eliminate these and narrow down the
problem.
But I am unable to work it out.

It verifies OK but when I run it gives me the runtime error re dividing by
zero. for  the following

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

If I change the Buy order from
Open Next Bar + (Average(Range,5)*Mult) stop;
to
at market, it gives the dividing by zero error

If I change (this is only for testing the code) the FirstDayPrft exit from
Open Next Bar + (Average(Range,5)*Mult)* 2 limit
to
Open Next Bar - (Average(Range,5)*Mult)* 2 limit
it gives the dividing by  zero error again

Code:

Inputs: Mult(1.2),LossPcnt(2.5),Low_Cl(2),ContSize(5000);

Vars: RunningCapital(1),Capital(15000),Conts(0),Max_Loss(0);
Vars:   MaxPntRsk(0);

Conts    = Floor((NetProfit+1)/ContSize) + 1;
RunningCapital = Capital + NetProfit;
MaxPntRsk   = ((LossPcnt/100)*RunningCapital)/BigPointValue;
Max_Loss  = Ceiling(MaxPntRsk/Conts);
If Max_Loss > Average(Truerange,34)
  then Max_Loss = Average(Truerange,34);
If Conts < 1  then Conts = 1;
If Conts > 10 then Conts = 10;

Condition10  = Close < Lowest(Close[1],Low_Cl);
Condition20  = Xaverage(C,13) < Xaverage(C,34);

If CurrentBar > 1 and MarketPosition <>1 then begin
 If  Condition10 and Condition20
 then buy(" Contracts") Conts Contracts at
     Open Next Bar + (Average(Range,5)*Mult) stop;
end;

If MarketPosition <>1 then begin
 Exitlong("FirstDayPrft") at
  Open Next Bar + (Average(Range,5)*Mult)* 2 limit;
 Exitlong("1stDayLoss") at
  (Open Next Bar + Average(Range,5)*Mult) - Max_loss stop;
end;

If MarketPosition = 1 then begin
 If open of next bar > entryprice then
  exitlong("BailOut") at market;
 exitlong("Max_Loss")EntryPrice - Max_loss stop;
end;




Mel



Mel