PureBytes Links
Trading Reference Links
|
Just reading through code (1) (not testing it) I note that you're really trying to create two PaintBars, one for the upside and one for the downside. But every PaintBar in TS4 requires two Plot statements. For example, you can write:
If switch=1 and low<=Lbb then begin
Plot1(Low,"Lo");
Plot2(H, "Hi");
Switch = 2;
End;
So if you want different colors for your paintbars you may wish to create two separate studies... or you can create one study and use the same two Plot statements for both upside and downside... But the PB's in this case will be the same color...
---- you wrote:
> 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;
> *****************
>
|