Page 1 of 1

Bollinger Color

Posted: Thu Jul 12, 2007 3:22 pm
by 9244858
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

Posted: Fri Jul 13, 2007 9:03 am
by Pep
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;

Posted: Fri Jul 13, 2007 11:24 am
by 9244858
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

Posted: Mon Jul 16, 2007 6:30 am
by Pep
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.

Posted: Mon Jul 16, 2007 7:44 am
by 9244858
Thank you verry much.
It works.
Cristina