Trendline with Snap to Point & Semi log Aware Trendline

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Trendline with Snap to Point & Semi log Aware Trendline

Post by Quant » Wed Feb 11, 2015 11:33 am

Here we have 2 requirements:
1] Draw Line with Snap to Point
This requires drawing a Line with "Snap to Point" option similar as Cursor Tool's Snap Feature.

2] Semi Log Aware Line [Dependent on requirement 1]
Say e.g. we have a normal Candle Series and we draw the line which is based on this candle series. Now assume that we changed this Candle to Logarithmic with log base equal to 10. Since the previously drawn line is based on Candle Series this line should now updated as per the Logarithmic Candle Series. In this transformation the line may change its appearance from straight line to curved line. Same can happen vice versa.

Please help us in solving above two requirements.

Christopher
Guru
Posts: 1229
Joined: Fri Nov 15, 2002 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Christopher » Wed Feb 11, 2015 1:29 pm

Hello Quant,

Would you be so kind as to send us some example code you have already written to implement these requirements of yours?

It would save us a lot of time to work on what you have already done rather than writing an application for you from scratch. If you could also send us some screenshots of what functionality you would like to see in your code but haven't been able to implement, that would also be greatly appreciated.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Quant » Thu Feb 12, 2015 6:41 am

We yet to start work on this, but we can explain you both the requirement in more detail.

1] Draw Line with Snap to Point (Check below Image 1):
As shown in the screenshot we draw two trend lines. The Pink Line is normal line without Snap to Point Option. Whereas the Green Line as you see are attached to series points. Green line is drawn using Snap to Point Option. Both Start and End points of Green Line are attached to CandleStick Series.
TrendLine.png
Image (1): Snap to Point Trend Line
TrendLine.png (31.9 KiB) Viewed 8431 times
2] Semi Log Aware Line
Image 2 shows Line Drawn on series whose Logarithmic Property is Set to True.
Whereas Image 3 shows the same Line on same series whose Logarithmic Property is Set to False.
By clearly looking at both the image, you can clearly make out the difference in Image 3 that the blue line is now has the appearance of Curved Line.
The line shown in Image 3 is actual Semi Log Aware Trend Line.
Semilog_Scale.png
Image (2): Line Drawn on Logarithmic Series
Semilog_Scale.png (26.35 KiB) Viewed 8413 times
Without_Semilog_Scale.png
Image (3): Line Drawn on Same Series (with Logarithmic = Off
Without_Semilog_Scale.png (27.33 KiB) Viewed 8415 times

Christopher
Guru
Posts: 1229
Joined: Fri Nov 15, 2002 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Christopher » Thu Feb 12, 2015 9:31 am

Quant,

A couple of questions:
1) which algorithm are you using to calculate the points that are drawn in the trendline?
2) the snap to point functionality ... how do you want this to work? Which if the OHLC (open, high, low, close) points do you want the line to snap to when the mouse is moved?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Quant » Thu Feb 12, 2015 11:39 am

Hi,

Currently we are not using any algorithm for calculating points that are drawn in the trendline. We are using Line Tool for drawing trendline.
I can suggest you algorithm that is TeeChart currently using for Tool "Nearest Point".

For the Snap Point functionality yes we want the line to snap when the mouse is moved.

Christopher
Guru
Posts: 1229
Joined: Fri Nov 15, 2002 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Christopher » Thu Feb 12, 2015 11:58 am

Quant wrote: Currently we are not using any algorithm for calculating points that are drawn in the trendline. We are using Line Tool for drawing trendline.
Okay ... so how do you expect the line to "bend" as you require? For this to happen more than two points (start, end) are necessary.
Quant wrote: I can suggest you algorithm that is TeeChart currently using for Tool "Nearest Point".
Please do not forget that even without the TeeChart source code you have access to this algorithm - the TeeChart.dll is not obfuscated, which means you can easily use tools such as reflector or ILSpy to copy code.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Quant » Thu Mar 26, 2015 8:35 am

Hi,
We did R&D on the mentioned requirement in this post, but we yet to get solution on this.
Please provide us with some sample code.

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

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Narcís » Thu Mar 26, 2015 9:06 am

Hello Quant,

To be able to understand which is your exact requirement you should answer the questions Christopher Ireland made you before:
Christopher wrote: 2) the snap to point functionality ... how do you want this to work? Which if the OHLC (open, high, low, close) points do you want the line to snap to when the mouse is moved?
Christopher wrote: Okay ... so how do you expect the line to "bend" as you require? For this to happen more than two points (start, end) are necessary.
Christopher wrote: Please do not forget that even without the TeeChart source code you have access to this algorithm - the TeeChart.dll is not obfuscated, which means you can easily use tools such as reflector or ILSpy to copy code.
Did you look at that, which problems did you come across?

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

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Quant » Thu Mar 26, 2015 12:27 pm

Hi,

1] Snap to Point Functionality should work on selected series data. It can be OHLC, Line or Volume etc.

2] I explained the same point in more details (with images), in this post. Yes sometimes we need more than two points to achieve this.

3] Currently we have not looked in your source code, but as we have to deliver these requirements asap, we do not have much time to follow this step. It would be very great if you help us in fulfilling these requirements.

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

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Narcís » Fri Mar 27, 2015 12:34 pm

Hi Quant,

You could try using NearestPoint tool GetNearestPoint method as Yeray explained here to snap points to your series.
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

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Quant » Tue May 26, 2015 12:28 pm

Hi,

We need an example for Semi Log Aware Trendline, which we have explained with image in this post.
We did our research on this but still we haven't found any solution.

Christopher
Guru
Posts: 1229
Joined: Fri Nov 15, 2002 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Christopher » Wed May 27, 2015 1:29 pm

Hello,
Quant wrote:We did our research on this but still we haven't found any solution.
Can you please explain the specific problems you encountered in your research of this functionality?

My colleague Narcís has been kind enough to produce a simple mock-up of what we understand as your requirement, which is here:

Code: Select all

    private Steema.TeeChart.Styles.Candle candle1;
    private Steema.TeeChart.Tools.NearestPoint nearestPoint1;

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      tChart1.Zoom.Direction = Steema.TeeChart.ZoomDirections.None;
      tChart1.Panning.Allow = Steema.TeeChart.ScrollModes.None;

      candle1 = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
      candle1.FillSampleValues();

      nearestPoint1 = new Steema.TeeChart.Tools.NearestPoint(candle1);
      nearestPoint1.Active = false;

      tChart1.MouseDown += tChart1_MouseDown;
      tChart1.MouseMove += tChart1_MouseMove;
      tChart1.MouseUp += tChart1_MouseUp;
    }

    void tChart1_MouseUp(object sender, MouseEventArgs e)
    {
      if (!multiPointLine && (index != -1))
      {
        AddNewPoint(new Point(e.X, e.Y));
      }
      index = -1;
    }

    private void AddNewPoint(Point point)
    {
      int newIndex = nearestPoint1.GetNearestPoint(point);
      tChart1[tChart1.Series.Count - 1].Add(candle1.XValues[newIndex], candle1.YValues[newIndex]);
    }

    void tChart1_MouseMove(object sender, MouseEventArgs e)
    {
      if (multiPointLine && (index != -1))
      {
        AddNewPoint(new Point(e.X, e.Y));
      }
    }

    private int index = -1;

    void tChart1_MouseDown(object sender, MouseEventArgs e)
    {
      index = nearestPoint1.GetNearestPoint(new Point(e.X, e.Y));

      if (index != -1)
      {
        tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
        tChart1[tChart1.Series.Count - 1].Add(candle1.XValues[index], candle1.YValues[index]);
      }
    }

    private bool multiPointLine = false;

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
      multiPointLine = checkBox1.Checked;
    }

    private void checkBox2_CheckedChanged(object sender, EventArgs e)
    {
      tChart1.Axes.Left.Logarithmic = checkBox2.Checked;
    }
I hope you can use this very simple example to further explain to us exactly what your requirements are.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Quant » Tue Jun 16, 2015 12:02 pm

Dear Steema,

We checked your code, but it is not what we expected. Last time we explained the same with some screenshots. Please take look of this post once again. If you still have difficulty to understand the same, please let us know.

Christopher
Guru
Posts: 1229
Joined: Fri Nov 15, 2002 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Christopher » Wed Jun 17, 2015 11:00 am

Quant wrote:We checked your code, but it is not what we expected. Last time we explained the same with some screenshots. Please take look of this post once again. If you still have difficulty to understand the same, please let us know.
Without a mathematical or algorithmic explanation of your requirement, I'm afraid we cannot help. Images are simply not enough as a basis for us to implement it, I'm afraid.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Trendline with Snap to Point & Semi log Aware Trendline

Post by Quant » Thu Sep 03, 2015 5:36 am

watch this video which explain semi log in Excel
*Line is converted to log curve *
http://www.youtube.com/watch?v=y55VmSIMBjE

for mathematical formula use below link
https://en.wikipedia.org/wiki/Semi-log_plot

Post Reply