How to display OHLC values from Candle series

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Martin
Newbie
Newbie
Posts: 1
Joined: Tue May 02, 2006 12:00 am

How to display OHLC values from Candle series

Post by Martin » Thu Apr 19, 2007 4:56 pm

I'm want to display the OHLC values of a Candle chart using the TAnnotationTool in the DBChart's OnMouseMove event. It appears I'm missing something because I'm not able to get the correct ValueIndex value to use with the TChartValueList properties.

I've tried using the TCursorTool but the OnChange ValueIndex is only set when Snap property is set to True. It also appears to snap to the correct bar based on both the X and Y mouse position. I cannot always use the TCursorTool OnChange or OnSnapChange events to display the OHLC values because it may be turned off.

Any suggestions or help is appreciated.
Thank you in advance.

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

Post by Yeray » Fri Apr 20, 2007 10:38 am

Hi Martin,

I think you should do something like following:

Code: Select all

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var ValueIndex: integer;
  high, low, open, close: double;
begin
  ValueIndex := Series1.Clicked(X,Y);

  if ValueIndex >= 0 then
  begin
    high := Series1.HighValues[ValueIndex];
    low := Series1.LowValues[ValueIndex];
    open := Series1.OpenValues[ValueIndex];
    close := Series1.CloseValues[ValueIndex];

    ChartTool1.Text := 'High: ' + floattostr(high) + '   Open: ' + floattostr(open) + '   Close: ' + floattostr(close) + '   Low: ' + floattostr(low)
  end;
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