Getting the Y value from a horizontal line.

Created at 21 May 2021, 00:11
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
HS

hslagter

Joined 28.04.2020

Getting the Y value from a horizontal line.
21 May 2021, 00:11


I am unable to get the Y value of an existing horizontal line. Drawing the line and immediately finding out the Y value is no problem. I want to be able to move a horizontal line and read the new value. I've tried with

Chart.ObjectHoverChanged + = OnChartObjectHoverChanged;

Chart.DragEnd + = OnDragEnd;

Chart.DragStart + = OnChartDragStart;

Chart.ObjectsSelectionChanged + = OnChartObjectsSelectionChanged;

I can get the name, comment, etc., but no Y value. A small example is sufficient.


@hslagter
Replies

hslagter
21 May 2021, 18:59

RE: I found it and I won't keep it for myself ;-).

hslagter said:

I am unable to get the Y value of an existing horizontal line. Drawing the line and immediately finding out the Y value is no problem. I want to be able to move a horizontal line and read the new value. I've tried with

Chart.ObjectHoverChanged + = OnChartObjectHoverChanged;

Chart.DragEnd + = OnDragEnd;

Chart.DragStart + = OnChartDragStart;

Chart.ObjectsSelectionChanged + = OnChartObjectsSelectionChanged;

I can get the name, comment, etc., but no Y value. A small example is sufficient.

        ChartHorizontalLine LowerLine;
        ChartHorizontalLine templine;

        protected override void OnStart()
        {
            LowerLine = Chart.DrawHorizontalLine("lowerline", Symbol.Bid, Color.Yellow, AlertLineThick, AlertLineStyle);
            LowerLine.IsInteractive = true;
        }

        protected override void OnTick()
        {
            templine = LowerLine;
            Chart.DrawStaticText("test", templine.Y.ToString("0.00000"), VerticalAlignment.Center, HorizontalAlignment.Center, Color.White);
        }
 


@hslagter