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.
How to display OHLC values from Candle series
Hi Martin,
I think you should do something like following:
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |