Page 1 of 1
Crosshair - add to CHART?
Posted: Sat May 10, 2014 8:47 am
by 16467044
Hi,
is it possible to add a crosshair not to a series, but to a chart?
Please see the screenshot: It has a crosshair tool added to the candle series.
Its vertical line does not reach the function series, which would be interesting to compare.
See red circle around the "not reaching".
So my question: is it possible to have a crosshair to 2 series or to a chart or to a series including its function?
Thanks,
Cheryll
Re: Crosshair - add to CHART?
Posted: Mon May 12, 2014 9:07 am
by yeray
Hi Cheryll,
I can't reproduce the problem here. What TeeChart version are you using?
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Re: Crosshair - add to CHART?
Posted: Tue May 13, 2014 4:13 pm
by 16467044
Hi,
everything default, done in half a minute:
Add a candlestick series, fill it with sample data.
Then add e.g. the RSI function and the cross-hair tool.
You will (probalby) see, that the crosshair will look "short" / not reach the RSI series - as on my screenshot.
This is normal for the tool / functions. At least for me.
For this reason I asked, what I can do as an alternavtive for a vertical line above ALL series.
I use TeeChart Pro v2012/13 VCL version.
Regards,
Cheryll
Re: Crosshair - add to CHART?
Posted: Wed May 14, 2014 9:00 am
by yeray
Hi Cheryll,
Chartist wrote:everything default, done in half a minute:
Add a candlestick series, fill it with sample data.
Then add e.g. the RSI function and the cross-hair tool.
You will (probalby) see, that the crosshair will look "short" / not reach the RSI series - as on my screenshot.
This is normal for the tool / functions. At least for me.
I must be missing some setting because this code:
Code: Select all
uses Chart, CandleCh, Series, TeeTools;
var Chart1: TChart;
candle1: TCandleSeries;
line1: TLineSeries;
rsiFunc1: TRSIFunction;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1:=TChart.Create(Self);
Chart1.Parent:=Self;
Chart1.Align:=alClient;
Chart1.View3D:=false;
Chart1.Legend.Visible:=false;
candle1:=Chart1.AddSeries(TCandleSeries) as TCandleSeries;
candle1.FillSampleValues;
line1:=Chart1.AddSeries(TLineSeries) as TLineSeries;
rsiFunc1:=TRSIFunction.Create(Self);
line1.SetFunction(rsiFunc1);
line1.DataSource:=candle1;
Chart1.Tools.Add(TCursorTool);
end;
Gives me this chart:
- 2014-05-14_1052.png (19.27 KiB) Viewed 17813 times
Can you please try the code above?
Does it work fine for you?
Do you see it's doing anything very different to what you explained?
Chartist wrote:For this reason I asked, what I can do as an alternavtive for a vertical line above ALL series.
You could also try with TColorLineTool.
Chartist wrote:I use TeeChart Pro v2012/13 VCL version.
I've tried the code above with different TeeChart versions (2012.05, 2012.06, 2012.07, 2013.08, 2013.09, 2014.10 and 2014.11) and I always got the cursor from the top to the bottom of the chart.
Re: Crosshair - add to CHART?
Posted: Tue Jul 08, 2014 5:11 pm
by 16467044
Hi,
how times fly!
This thing is that long on my ToDo list.
Thank you for your reply.
Du you think, it has to do something with the scaling?
I cannot "remove" it, because by removing these lines, I remove the lower part, where the vertical line shall pass through.
I wrote this in my code.
original
DBChart_A_Kontrakt.Axes.Left.EndPosition:=100 - SubChartProzent;
for you to understand
SubChartProzent:=15;
DBChart_1.Axes.Left.EndPosition:=100 - SubChartProzent;
=> this shall make, that the main chart takes a space from 85% from above. And the subchart takes 15% at the lower edge of my chart.
Warm Regards,
Cheryll
Re: Crosshair - add to CHART?
Posted: Thu Jul 10, 2014 1:14 pm
by narcis
Hi Cherryl,
I'm sorry but I don't understand what you mean. Could you please send
a Short, Self Contained, Correct (Compilable), Example project to reproduce the problem here?
Thanks in advance.
Re: Crosshair - add to CHART?
Posted: Thu Jul 17, 2014 3:40 pm
by 16467044
Thank you for your reply.
This is hard, but not impossible with your help. The thing is, that with YOUR code, I cannot do what done with my code (listed above).
So I started a new form and if you allow we try to meet on this base. The project reads this (nothing but your above example fit into my form Form_MPs):
procedure TForm_MPs.erzeugen; //FormCreate(Sender: TObject);
begin
Application.CreateForm(TForm_MPs, Form_MPs);
Chart_MP:=TChart.Create(Form_MPs);
Chart_MP.Parent:=Form_MPs;
Chart_MP.Align:=alClient;
Chart_MP.View3D:=false;
Chart_MP.Legend.Visible:=false;
candle1:=Chart_MP.AddSeries(TCandleSeries) as TCandleSeries;
candle1.FillSampleValues;
line1:=Chart_MP.AddSeries(TLineSeries) as TLineSeries;
rsiFunc1:=TRSIFunction.Create(Self);
line1.SetFunction(rsiFunc1);
line1.DataSource:=candle1;
Chart_MP.Tools.Add(TCursorTool);
Form_MPs.BringToFront;
Form_MPs.Show;
end;
What I cannot do is the scaling. I make you a screenshot to show you WHICH scaling.
Sincerely,
Cheryll
Re: Crosshair - add to CHART?
Posted: Fri Jul 18, 2014 7:32 am
by narcis
Hi Cheryll,
Thanks for the info.
In that case you can use a custom axis that occupies 5% of the chart for the RSI function. You'll find several examples at
All Features\Welcome!\Functions\Financial in the new features demo, available at TeeChart's program group from the binary version. For example:
RSI\Calculating RSI,
Momentum Div and
CLV (Accum/Distrib) examples. You'll also find more information about axes settings in Tutorial 4. Tutorials are also available at TeeChart's program group.
Finally, you might be interested in associating the cursor tool to the candle series:
Code: Select all
(Chart_MP.Tools.Items[0] as TCursorTool).Series:=candle1;
So, all of this applied to your code, could be something like this:
Code: Select all
uses Chart, CandleCh, Series, TeeTools, TeEngine;
procedure TForm1.FormCreate(Sender: TObject);
var
Chart_MP: TChart;
candle1: TCandleSeries;
line1: TLineSeries;
rsiFunc1: TRSIFunction;
MyAxis : TChartAxis;
begin
//Application.CreateForm(TForm_MPs, Form_MPs);
Chart_MP:=TChart.Create(Self);
Chart_MP.Parent:=Self;
Chart_MP.Align:=alClient;
Chart_MP.View3D:=false;
Chart_MP.Legend.Visible:=false;
candle1:=Chart_MP.AddSeries(TCandleSeries) as TCandleSeries;
candle1.FillSampleValues;
line1:=Chart_MP.AddSeries(TLineSeries) as TLineSeries;
rsiFunc1:=TRSIFunction.Create(Self);
line1.SetFunction(rsiFunc1);
line1.DataSource:=candle1;
MyAxis := TChartAxis.Create(Chart_MP);
line1.CustomVertAxis := MyAxis;
MyAxis.StartPosition:=95;
MyAxis.EndPosition:=100;
Chart_MP.Axes.Left.EndPosition:=95;
Chart_MP.Tools.Add(TCursorTool);
(Chart_MP.Tools.Items[0] as TCursorTool).Series:=candle1;
//Form_MPs.BringToFront;
//Form_MPs.Show;
end;
Hope this helps!
Re: Crosshair - add to CHART?
Posted: Fri Jul 18, 2014 9:40 am
by 16467044
Hi Narcis,
thank you for your reply.
And now we did it. We have a code now, where the original problem occurs (pls. read original posting).
I send you a screenshot. The split of the axis makes it.
What can I do, that the cursor goes down to the bottom?
I do not have only an RSI. I have several extra axis of which it is hard to see exactly which candle they belong to.
If the cursor tool does not do it, I am grateful for any work-around.
Thanks,
Cheryll
Re: Crosshair - add to CHART?
Posted: Fri Jul 18, 2014 9:53 am
by narcis
Hi Cherryll,
Ok, back to your original question:
is it possible to have a crosshair to 2 series
Yes. However, your custom axis scenario doesn't allow this.
or to a chart
Yes, not assigning it to a specific series. Again, this doesn't apply for such custom axes charts.
or to a series including its function?
Yes, you could add another cursor tool associated to the function series, for example:
Code: Select all
Chart_MP.Tools.Add(TCursorTool);
(Chart_MP.Tools.Items[1] as TCursorTool).Series:=line1;
You could even try implementing horizontal cursor synchronization similar to what's shown in the
All Features\Welcome!\Tools\Cursor\Synchronizing Two in the new features demo, available at TeeChart's program group.
Would that fit your needs?
Re: Crosshair - add to CHART?
Posted: Wed Jul 23, 2014 10:14 am
by 16467044
Thank you so much!
I love it and have never seen this before, - although I scrolled the features help many times.
I probably will use this for many other purposes as well.
Cheryll
Re: Crosshair - add to CHART?
Posted: Thu Jul 24, 2014 8:16 am
by 10050769
Hello Cheryll,
Thanks for your feedback. We are glad that our suggestion, has worked for you
.
Thanks in advance,