Candle sticks and weekends

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Marius
Newbie
Newbie
Posts: 28
Joined: Tue Jul 29, 2008 12:00 am

Candle sticks and weekends

Post by Marius » Fri Jul 17, 2009 2:07 pm

Hi

I have a candlestick chart where I add data using

Code: Select all

.AddCandle(date, open, max, min, close)
When I display the chart I get blanks for the weekend (so basically five values and then two blanks over and over again)

How can I compress it so it that hides the weekends?

I see in the doco that you suggest using an incremental integer instead of date and then use labels but I sometimes overlay two or three other charts and do a lot of logic to figure out the scale of the X axis based on the dates... But most of the time the Candle stick chart is displayed on it's own. There isn't another way than the incremental integer is there?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Candle sticks and weekends

Post by Narcís » Fri Jul 17, 2009 2:17 pm

Hi Marius,

No, there's no alternative I can think of for now. Which are the exact problems you are having one using several charts together? You may get date logic retrieving label values from the series.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Marius
Newbie
Newbie
Posts: 28
Joined: Tue Jul 29, 2008 12:00 am

Re: Candle sticks and weekends

Post by Marius » Fri Jul 17, 2009 2:22 pm

Just wanted to avoid rewriting it all....

Thanks anyway :-)

Marius
Newbie
Newbie
Posts: 28
Joined: Tue Jul 29, 2008 12:00 am

Re: Candle sticks and weekends

Post by Marius » Mon Jul 20, 2009 10:06 am

Narcis

Further to my earlier question....

I've now changed my code to AddCandle using a sequential number.

Code: Select all

i := sCustom1.AddCandle(sCustom1.Count, FieldByName('OpeningValue').AsFloat, dMax, dMin, FieldByName('ClosingValue').AsFloat);
sCustom1.Labels[i] := FormatDateTime('d mmm yy', Trunc(FieldByName('IndexDate').AsDateTime));
When it comes to adjusting the X axis I use the following

Code: Select all

chCustom.BottomAxis.Increment := 5;
chCustom.BottomAxis.MinorTickCount := 4;
chCustom.BottomAxis.LabelStyle := talText;
It displays the labels as dates but it no longer respects the Increment value. I've set it to display every 5 labels but it fits them in based on a best fit approach. If I comment out the LabelStyle line then the Increment is respected.

Any ideas?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Candle sticks and weekends

Post by Yeray » Mon Jul 20, 2009 11:54 am

Hi Marius,

Could you try with an increment like following?

Code: Select all

Chart1.BottomAxis.Increment := DateTimeStep[dtOneWeek];
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Marius
Newbie
Newbie
Posts: 28
Joined: Tue Jul 29, 2008 12:00 am

Re: Candle sticks and weekends

Post by Marius » Mon Jul 20, 2009 12:46 pm

Hi Yeray

Unfortunately your suggestion does not work. DateTimeStep[dtOneWeek] simply returns 7. I need the interval to be 5 as I have removed the weekends...
Either way, even if I wanted 7 as an interval, it is still not respected...

Marius

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Candle sticks and weekends

Post by Yeray » Mon Jul 20, 2009 2:04 pm

Hi Marius,

Yes, excuse me. I haven't understood well the problem. Setting the bottom axis labels style to show the series labels text, the increment can't be used as normally. then I recommend you to use OnGetAxisLabel event to show or hide the text. Here you have an example:

Code: Select all

var LabelsCount: Integer;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Series1.Clear;
  Chart1.View3D := false;

  for i:=0 to 20 do
  begin
    series1.AddCandle(i, random*100+600, random*100+800, random*100, random*100+200);
    series1.Labels[i] := FormatDateTime('d mmm yy', Now-20+i);
  end;
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  if (Sender = Chart1.Axes.Bottom) then
  begin
    if (LabelsCount mod 5 <> 0) then
      LabelText := '';

    LabelsCount := LabelsCount+1;
  end;
end;

procedure TForm1.Chart1BeforeDrawAxes(Sender: TObject);
begin
  LabelsCount := 2;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply