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

Ela code and FP error



PureBytes Links

Trading Reference Links

I tried to write PaintBar code to identify certain patterns which started 
with price exceeding Bollinger Bands.  If the high exceeded the upper BB, no 
paint bar but the setup was started.  The PB should show when the low exceeds 
the lower BB (after the upper band was hit first and vice versa).

The first code does not produce any paintbars while the second produces a 
floating point error that crashes TS4.  Can anyone explain how to correct 
these problems and what it is that is causing the FP error problem?  Thanks 
for any help.
Lynn

(1)
Inputs:Len(39), SDEV(2),LSDEV(-2);
Vars: switch(0),Ubb(0),Lbb(0);

Ubb=BollingerBand(C, LEN, SDEV);
Lbb=BollingerBand(C, LEN, LSDEV);

{ Switch=1 == we painted High last.  =2 == we painted Low last. }

If switch=1 and low<=Lbb then begin
  Plot1(Low,"Lo");
  Switch = 2;
  end;
If switch=2 and H>Ubb then begin
  Plot2(H,"Hi");
  Switch = 1;
  end;
***************
(2)
nputs:Len(39), SDEV(2),LSDEV(-2);
Vars: switch(0),Ubb(0),Lbb(0);

Ubb=BollingerBand(C, LEN, SDEV);
Lbb=BollingerBand(C, LEN, LSDEV);

{ Switch=1 == we painted High last.  =2 == we painted Low last. }

If switch<>2 and low<=Lbb then begin
  Plot1(Low,"Lo");
  Switch = 2;
  end;
If switch<>1 and H>Ubb then begin
  Plot2(H,"Hi");
  Switch = 1;
  end;
*****************