Question re: Object Dragging

Created at 29 Nov 2023, 18:14
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!
GI

Giorgi_1

Joined 23.06.2023

Question re: Object Dragging
29 Nov 2023, 18:14


Hi guys, 

I'm looking to get some information re: dragging objects in cTrader. More specifically, i'd like my cBot to recognise that i've dragged a horizontal line from position A to position B. 

Can anyone recommend anything? I've tried Chart.DragStart and Chart.DragEnd, but i don't believe this is what i'm looking for. I want to monitor a specific object, in this case a horizontal line. 

Any advice is appreciated. 

Thanks,


@Giorgi_1
Replies

firemyst
03 Dec 2023, 11:28 ( Updated at: 04 Dec 2023, 08:32 )

_

First of all, you'd have to register an event that the chart has been updated:

Chart.ObjectsUpdated += botHorizontalLineUpdated;

Define the method and do what you need:

private void botHorizontalLineUpdated(ChartObjectsUpdatedEventArgs args)

{

    //these lines are known as small chart horizontal lines

    if (args.ChartObjects[0].GetType().Name == "SmallChartHorizontalLine")
    {
        //Get your line
		ChartHorizontalLine obj = (ChartHorizontalLine)args.Chart.FindObject(TheNameOfYourLine);
		//Do what you need to from here
    }

}

@firemyst