create RECTANGLE_LABEL

[Deleted]  

I would like a RECTANGLE_LABEL on my chart.

But it comes me only a LABEL.

Where is the error?

#include <ChartObjects\ChartObjectsTxtControls.mqh>

void OnStart()
  {
   CChartObjectRectLabel *m_anker;
   m_anker=new CChartObjectRectLabel;

   m_anker.Create(0,"Text",0,0,0);

  }

 

 
FinGeR:

I would like a RECTANGLE_LABEL on my chart.

But it comes me only a LABEL.

Where is the error?

Hi FinGeR,

Because you're using class to control text instead class to control object rectangle like ChartObjectsShapes.mqh.

If I confuse using classes, I'll go the 'old fashion' way, using ObjectCreate() function.

:D 

[Deleted]  

thanks onewithzachy,

but CChartObjectRectLabel  located in ChartObjectsTxtControls.mqh

 
FinGeR:

thanks onewithzachy,

but CChartObjectRectLabel  located in ChartObjectsTxtControls.mqh

Dear FinGeR,

My apology, you are right, obviously I didn't read your code carefully and didn't check the entire content of ChartObjectsTxtControls.mqh.

I'm a little busy at the moment and I just check my CChartObjectRectLabel return is true but no object. 

:D 

 

Hi,

You should pass rect sizes on create function:

#include <ChartObjects\ChartObjectsTxtControls.mqh>

void OnStart()
  {
   CChartObjectRectLabel *m_anker;
   m_anker=new CChartObjectRectLabel;

   m_anker.Create(0,"Text",0,0,0, 50, 30);

  }

Because CChartObjectRectLabel is inherited from CChartObjectLabel, and both parent - child have same Create method. The way you call Create will run the parent's method instead of the child (which is create a label object).

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
[Deleted]  
meisme:

Hi,

You should pass rect sizes on create function:

Because CChartObjectRectLabel is inherited from CChartObjectLabel, and both parent - child have same Create method. The way you call Create will run the parent's method instead of the child (which is create a label object). 

Now it works. 

Thank you very much. 

 

No problem :)
 
meisme:

Hi,

You should pass rect sizes on create function:

Because CChartObjectRectLabel is inherited from CChartObjectLabel, and both parent - child have same Create method. The way you call Create will run the parent's method instead of the child (which is create a label object). 

Hi meisme,

Thanks for that, LOL, I coded my code wrong, no wonder there is no object.

There's no sample in MT5 too. 

:D