Bollinger Color

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
quickweb
Newbie
Newbie
Posts: 13
Joined: Mon Apr 16, 2007 12:00 am
Contact:

Bollinger Color

Post by quickweb » Thu Jul 12, 2007 3:22 pm

Hi,
I don't know what I am doing wrong with settings for bollinger function properties because the LowBand color is not updated. The color is update in the same time with highband and with color of this.

I create a function with default properties, and after that assign new properties:
// set Bollinger function properties

TLineSeries* fSeries = Object->series;
TBollingerFunction* f = (TBollingerFunction*)fSeries->FunctionType;
fSeries->SeriesColor = clGreen;
fSeries->Pen->Style = psSolid;
fSeries->Pen->Width = 1;
fSeries->YValues->ValueSource = "Close";
f->Period = 14;
fSeries->FunctionType->Period = f->Period;
f->Deviation = 2;
f->Exponential = true;
f->LowBandPen->Color = clAqua;
f->LowBandPen->Style = psSolid;
fSeries->CheckDataSource();


Thanks for your help,
Cristina

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jul 13, 2007 9:03 am

H Cristina,

using the following code works fine here, could you please check if it works for you ? (appologies for Delphi code) :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
    MySeries: TCandleSeries;
    MyFunctionSeries: TLineSeries;
begin
  Chart1.View3D := false;
  MySeries:=TCandleSeries.Create(Self);
  MySeries.ParentChart := Chart1;
  // you must create second series for Bollinger
  MyFunctionSeries := TLineSeries.Create(Chart1);
  MyFunctionSeries.ParentChart := Chart1;
  MyFunctionSeries.SetFunction(TBollingerFunction.Create(Chart1));
  // connect original series to MyFunctionSeries
  // now MyFunctionSeries will get it's (calculated) data from MySeries
  MyFunctionSeries.DataSource := MySeries;
  With (MyFunctionSeries.FunctionType as TBollingerFunction) do
  begin
    Deviation:=2;
    Period:=14;
    Exponential:=true;
    LowBandPen.Style := psDash;
    LowBandPen.Color := clnone;
  end;
  // populate date and refresh Bollinger function/series
  MySeries.FillSampleValues(100);
  MyFunctionSeries.CheckDataSource;

  With (MyFunctionSeries.FunctionType as TBollingerFunction) do
  begin
    LowBandPen.Style := psSolid;
    LowBandPen.Width := 2;
    LowBandPen.Color := clAqua;
  end;
end;

quickweb
Newbie
Newbie
Posts: 13
Joined: Mon Apr 16, 2007 12:00 am
Contact:

Post by quickweb » Fri Jul 13, 2007 11:24 am

Hi,
I think, my code is the same (in C++).
TBollingerFunction* f = (TBollingerFunction*)fSeries->FunctionType;
f->LowBandPen->Color = clAqua;
f->LowBandPen->Style = psSolid;

More than that when I read the lowbandpen color I read the right color.
But the series are drawn both with fSeries color (the parent series).

Thank you for your quick answer,
cristina

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Jul 16, 2007 6:30 am

Hi cristina,

please try to change the order of the line in the code, this could be the cause. Try to post the lines where the lowbandpen color is changed after the CheckDataSource line.

quickweb
Newbie
Newbie
Posts: 13
Joined: Mon Apr 16, 2007 12:00 am
Contact:

Post by quickweb » Mon Jul 16, 2007 7:44 am

Thank you verry much.
It works.
Cristina

Post Reply