Drawing special symbols on Candlestick chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Rangarajan
Newbie
Newbie
Posts: 10
Joined: Fri Dec 10, 2021 12:00 am

Drawing special symbols on Candlestick chart

Post by Rangarajan » Wed Jan 26, 2022 4:19 am

I am displaying a Candle series in a Chart window. Based on some algorithm, I would like to display some special symbol (say, up triangle, down triangle, arrow, etc.) on some elements of the series. The symbol may have to be displayed either above the candlestick or below it. How can I do this? Obviously, because the symbol is logically "tied" to certain candlesticks, they should not vanish when I zoom or scroll the chart.

- Rangarajan

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

Re: Drawing special symbols on Candlestick chart

Post by Yeray » Wed Jan 26, 2022 11:15 am

Hello Rangarajan,

You could use a TPointSeries and use OnGetPointerStyle to modify its pointers as you wish. Ie:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  //...
  with TPointSeries(Chart1.AddSeries(TPointSeries)) do
  begin
    Pointer.Size:=6;

    AddXY(candleSeries.XValue[2], candleSeries.HighValues[2]);
    AddXY(candleSeries.XValue[6], candleSeries.LowValues[6]);

    OnGetPointerStyle:=SeriesGetPointerStyle;
  end;
end;

function TForm1.SeriesGetPointerStyle(Sender: TChartSeries;
  ValueIndex: Integer): TSeriesPointerStyle;
begin
  case ValueIndex of
    0: Result:=psTriangle;
    1: Result:=psDownTriangle;
  end;
end;
Project1_2022-01-26_12-08-04.png
Project1_2022-01-26_12-08-04.png (13.17 KiB) Viewed 8642 times
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

Rangarajan
Newbie
Newbie
Posts: 10
Joined: Fri Dec 10, 2021 12:00 am

Re: Drawing special symbols on Candlestick chart

Post by Rangarajan » Wed Jan 26, 2022 12:33 pm

Looks good, thanks. Let me try this.

- Rangarajan

Rangarajan
Newbie
Newbie
Posts: 10
Joined: Fri Dec 10, 2021 12:00 am

Re: Drawing special symbols on Candlestick chart

Post by Rangarajan » Thu Feb 03, 2022 11:50 am

Thanks again. It works as expected.

1) How would I handle the case where I need to draw vertical lines (in different colours) on candlestick chart, instead of symbols? The vertical lines need to span the entire height of the chart window without any specific Y values.
2) Is it possible to display arbitrary information when moving the mouse over each candlestick element? Or when clicking on a specific element?

- Rangarajan

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

Re: Drawing special symbols on Candlestick chart

Post by Yeray » Thu Feb 03, 2022 12:02 pm

Hello Rangarajan,
Rangarajan wrote:
Thu Feb 03, 2022 11:50 am
1) How would I handle the case where I need to draw vertical lines (in different colours) on candlestick chart, instead of symbols? The vertical lines need to span the entire height of the chart window without any specific Y values.
This sounds like the TColorLineTool. Take a look at the ColorLine example in the Features Demo shipped with the installation.
Tee9new_2022-02-03_12-58-42.png
Tee9new_2022-02-03_12-58-42.png (250.87 KiB) Viewed 8560 times
Rangarajan wrote:
Thu Feb 03, 2022 11:50 am
2) Is it possible to display arbitrary information when moving the mouse over each candlestick element? Or when clicking on a specific element?
Have you seen the MarksTipTool?
Tee9new_2022-02-03_13-01-18.png
Tee9new_2022-02-03_13-01-18.png (278.68 KiB) Viewed 8560 times
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

Rangarajan
Newbie
Newbie
Posts: 10
Joined: Fri Dec 10, 2021 12:00 am

Re: Drawing special symbols on Candlestick chart

Post by Rangarajan » Thu Feb 03, 2022 2:03 pm

Super! Thanks.

- Rangarajan

Post Reply