MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Automated Trading and Strategy Testing Forum

MQL5 Cookbook: Analyzing Position Properties in the MetaTrader 5 Strategy Tester MQL5 Cookbook: Analyzing Position Properties in the... Average Directional Movement Index Wilder Indicator
Average Directional Movement Index Wilder
Author: MetaQuotes
Subscribe to signal
Long Term Swap Earner EURNZD
53.14%, 761.01 USD
Ticks MomentumTicks Momentum Try product
Ticks Momentum
Author: dupter
Screenshot
GBPJPY, H1
Demo

// create RECTANGLE_LABEL

To add comments, please log in or register

Alexander Piechotta
4435
FinGeR 2012.07.03 17:51

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);

  }

 

 

Debugging MQL5 Programs
This article is intended primarily for the programmers who have already learned the language but have not fully mastered the program development yet. It reveals some debugging techniques and presents a combined experience of the author and many other programmers.
onewithzachy
954
onewithzachy 2012.07.03 18:08
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 

Alexander Piechotta
4435
FinGeR 2012.07.03 18:22

thanks onewithzachy,

but CChartObjectRectLabel  located in ChartObjectsTxtControls.mqh

onewithzachy
954
onewithzachy 2012.07.03 19:31
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 

meisme
38
meisme 2012.07.03 19:47

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).




Alexander Piechotta
4435
FinGeR 2012.07.03 20:12
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. 

meisme
38
meisme 2012.07.03 20:17

No problem :)
onewithzachy
954
onewithzachy 2012.07.04 03:01
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 

/

To add comments, please log in or register