Crosshair - add to CHART?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Crosshair - add to CHART?

Post by Chartist » Sat May 10, 2014 8:47 am

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
Attachments
ChartCrosshair.jpg
ChartCrosshair.jpg (56.16 KiB) Viewed 17020 times
Cheryll

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

Re: Crosshair - add to CHART?

Post by Yeray » Mon May 12, 2014 9:07 am

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?
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

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: Crosshair - add to CHART?

Post by Chartist » Tue May 13, 2014 4:13 pm

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
Cheryll

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

Re: Crosshair - add to CHART?

Post by Yeray » Wed May 14, 2014 9:00 am

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
2014-05-14_1052.png (19.27 KiB) Viewed 16945 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.
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

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: Crosshair - add to CHART?

Post by Chartist » Tue Jul 08, 2014 5:11 pm

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
Cheryll

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Crosshair - add to CHART?

Post by Narcís » Thu Jul 10, 2014 1:14 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: Crosshair - add to CHART?

Post by Chartist » Thu Jul 17, 2014 3:40 pm

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
Attachments
Crosshair_Project.jpg
Crosshair_Project.jpg (201.14 KiB) Viewed 16797 times
Cheryll

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Crosshair - add to CHART?

Post by Narcís » Fri Jul 18, 2014 7:32 am

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!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: Crosshair - add to CHART?

Post by Chartist » Fri Jul 18, 2014 9:40 am

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
Attachments
CutProblem.jpg
CutProblem.jpg (167.69 KiB) Viewed 16789 times
Cheryll

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Crosshair - add to CHART?

Post by Narcís » Fri Jul 18, 2014 9:53 am

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?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: Crosshair - add to CHART?

Post by Chartist » Wed Jul 23, 2014 10:14 am

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
Cheryll

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Crosshair - add to CHART?

Post by Sandra » Thu Jul 24, 2014 8:16 am

Hello Cheryll,

Thanks for your feedback. We are glad that our suggestion, has worked for you :).

Thanks in advance,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply