Page 1 of 1

How to display OHLC values from Candle series

Posted: Thu Apr 19, 2007 4:56 pm
by 9346233
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.

Posted: Fri Apr 20, 2007 10:38 am
by yeray
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;