Can I make OBJ_TREND line a member/property of a class?

 

I've got a subclass of CObject, which will plot a trend line on the chart.

At some point the end point of the line has to be changed (I know how to do that part).

However, I have to find the line object, which up until now, I did by looping over all chart objects looking for a string tag I put in its name.

Is it possible to simply make this line a property of my class, so I can easily access it as myObject.line?


EDIT: Is the CChartObjectTrend the object we are accessing through the OBJ_ enumeration?


Thanks for any help!

 
ZetaTrader:

I've got a subclass of CObject, which will plot a trend line on the chart.

At some point the end point of the line has to be changed (I know how to do that part).

However, I have to find the line object, which up until now, I did by looping over all chart objects looking for a string tag I put in its name.

Is it possible to simply make this line a property of my class, so I can easily access it as myObject.line?


EDIT: Is the CChartObjectTrend the object we are accessing through the OBJ_ enumeration?


Thanks for any help!


I managed to create an object of the above class:

#include <ChartObjects/ChartObjectsLines.mqh>


CChartObjectTrend *line = new CChartObjectTrend();

line.Create(0, "line", 0, x1, y1, x2, y2);


// All common properties of OBJ_TREND can be accessed this way

line.Color(clrYellow);

line.Hidden(false);


// Assign to my object to access it and modify parameters later on.

myObject.line = line


But it will not plot on the chart. Is there a step missing?


EDIT: When I try to print myObject.line.Time(1) it will give that 1970s date, same for price (always the same coordinate value). It seems the properties aren't being assigned/saved properly.

 

It seems I've found the issue.

Just for testing purposes, I didn't bother to give each line an individual name when creating the lines.


It seems MT will not allow to draw another object (of the same type only?).

In fact, the first line was drawn.


Can someone confirm that? 

Thank you!

Reason: