Page 1 of 1
How to delete a fibonacci object
Posted: Mon May 13, 2013 9:21 am
by 16562051
Hi,
There are multiple TFibonacciTool objects on my chart.
Is there a way to perform delete operation by clicking one of them? thanks.
Re: How to delete a fibonacci object
Posted: Mon May 13, 2013 11:45 am
by yeray
Hi,
At the moment there isn't a clicked function for the TFibonacciTool. I've added it to the wish list to be implemented in future releases (TV52016571).
In the meanwhile you could try to do it manually.
Here it is an example that works for a series with multiple TFibonacciTools. However in this example I'm only calculating if the trending line is being clicked, not for the levels. For the levels you'll have to loop the levels, calculate the lines where they are drawn and check them as I do for the trend line.
Code: Select all
var MDown: TPoint;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
Chart1.View3D:=false;
Chart1.AddSeries(TCandleSeries).FillSampleValues(35);
for i:=0 to 2 do
begin
with Chart1.Tools.Add(TFibonacciTool) as TFibonacciTool do
begin
StartX:=(Chart1[0] as TCandleSeries).DateValues[i*10];
StartY:=(Chart1[0] as TCandleSeries).CloseValues[i*10];
EndX:=(Chart1[0] as TCandleSeries).DateValues[(i+1)*10];
EndY:=(Chart1[0] as TCandleSeries).CloseValues[(i+1)*10];
DrawStyle:=fsRetracement;
end;
end;
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
MDown.X:=X;
MDown.Y:=Y;
end;
procedure TForm1.Chart1Click(Sender: TObject);
var i: Integer;
begin
for i:=0 to Chart1.Tools.Count-1 do
if Chart1.Tools[i] is TFibonacciTool then
with Chart1.Tools[i] as TFibonacciTool do
begin
if ((DrawStyle=fsFan) or (DrawStyle=fsArc)) then
begin
if PointInLine(MDown, Chart1.Axes.Bottom.CalcPosValue(StartX), Chart1.Axes.Left.CalcPosValue(StartY),
Chart1.Axes.Bottom.CalcPosValue(EndX), Chart1.Axes.Left.CalcPosValue(EndY)) then
begin
Active:=false;
exit;
end;
if DrawStyle=fsFan then
begin
end
else //DrawStyle=fsArc
begin
end;
end
else
begin //DrawStyle=fsRetracement
if PointInLine(MDown, Chart1.Axes.Bottom.CalcPosValue(StartX), Chart1.Axes.Left.CalcPosValue(StartY),
Chart1.Axes.Bottom.CalcPosValue(EndX), Chart1.Axes.Left.CalcPosValue(StartY)) or
PointInLine(MDown, Chart1.Axes.Bottom.CalcPosValue(StartX), Chart1.Axes.Left.CalcPosValue(EndY),
Chart1.Axes.Bottom.CalcPosValue(EndX), Chart1.Axes.Left.CalcPosValue(EndY)) then
begin
Active:=false;
exit;
end;
end;
end;
end;
Re: How to delete a fibonacci object
Posted: Tue May 14, 2013 3:39 am
by 16562051
Nice! Thanks.