Get Chart value (x,y) from Chart object

07 Feb 2019, 10:24Get Chart value (x,y) from Chart object#1
Rony Sitepuposts: 11since: 30 Jan 2017

How do we get position value of manually drawn chart object..?

 

Best Regards
RKS

07 Feb 2019, 10:44#2
Panagiotis Charalampousposts: 2168since: 13 Jan 2017

Hi Rony,

Which objects are you referring to? There is no one set of coordinates for any chart object. For example, a trend line has two sets of coordinates for the start and end points. Also you can calculate the coordinates for all the points in between.

Best Regards,

Panagiotis

 


Head of Community Management at cTrader
07 Feb 2019, 11:09#3
Rony Sitepuposts: 11since: 30 Jan 2017

hello...

lets say i want to get the cordinate of x1,y1,x2, and y2 of a manual drawn rectangle.

 

 

how do we do it..?

07 Feb 2019, 11:39#4
Panagiotis Charalampousposts: 2168since: 13 Jan 2017

Hi Rony,

Use the properties below

            ChartRectangle rectangle;
            rectangle.Time1;
            rectangle.Time2;
            rectangle.Y1;
            rectangle.Y2;

Best Regards,

Panagiotis


Head of Community Management at cTrader
07 Feb 2019, 17:08RE:#5
Rony Sitepuposts: 11since: 30 Jan 2017

I see ...

 we can access that values from "chart rectangle "

 

however , how do  we refer the manual drawn rectangle to   the "rectangle " variable..?

 

can i linked it through these code..?

 

 

Thank you in advance

 

 


   void OnChartObjectAdded(ChartObjectAddedEventArgs obj)
        {


            

chartrectangle ax = obj.chartobject;




        }

 

 

 

Panagiotis Charalampous said:

Hi Rony,

Use the properties below

            ChartRectangle rectangle;
            rectangle.Time1;
            rectangle.Time2;
            rectangle.Y1;
            rectangle.Y2;

Best Regards,

Panagiotis

 

08 Feb 2019, 09:18#6
Panagiotis Charalampousposts: 2168since: 13 Jan 2017

Hi Rony,

See below

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{

    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        protected override void OnStart()
        {
            Chart.ObjectAdded += OnChartObjectAdded;
        }

        void OnChartObjectAdded(ChartObjectAddedEventArgs obj)
        {
            if (obj.ChartObject is ChartRectangle)
            {
                ChartRectangle rectangle = (ChartRectangle)obj.ChartObject;
                Print(rectangle.Time1);
                Print(rectangle.Time2);
                Print(rectangle.Y1);
                Print(rectangle.Y2);
            }
        }

    }
}

Best Regards,

Panagiotis


Head of Community Management at cTrader
08 Feb 2019, 10:38#7
Rony Sitepuposts: 11since: 30 Jan 2017

Thank you so much...

it is working, 

 

i will applied it to another kind of object...