ChartObjectUpdatedEventArgs is obsolete

Created at 13 Jan 2022, 00:28
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!
FV

FVAp

Joined 11.05.2020

ChartObjectUpdatedEventArgs is obsolete
13 Jan 2022, 00:28


I gotta change "ChartObjectUpdatedEventArgs" to "ChartObjectsUpdatedEventArgs"

I dont want all objects in the chart to be updated, only the VerticalLine with a specific name, so in "ChartObjectUpdatedEventArgs" I write like this:

     if (obj.ChartObject.ObjectType == ChartObjectType.VerticalLine)

      {       var x_Name = "VerticalLine_name"

                if (obj.ChartObject.Name == x_Name) 

                 {

                 }

       };

How can I write these two "IF" statements in the new "ChartObjectsUpdatedEventArgs" ?


@FVAp
Replies

amusleh
13 Jan 2022, 08:18

Hi,

The new event args gives you all the chart objects that were updated, not just one object, because multiple objects can be updated at the same time.

To find the object that you are looking for you can use Linq, ex:

        private void Chart_ObjectsUpdated(ChartObjectsUpdatedEventArgs obj)
        {
            var verticalLine = obj.ChartObjects.FirstOrDefault(iObject => iObject.ObjectType == ChartObjectType.VerticalLine
                && iObject.Name.Equals("VerticalLine_name", StringComparison.OrdinalIgnoreCase));

            if (verticalLine != null)
            {
            }
        }

Here I check if there is an updated object that's vertical line and its name is "VerticalLine_name", if there is such an object we will get it otherwise the result will be null.


@amusleh