How can I read the text of the label that MQL4 draw when I override an H-line object with the mouse?

To add comments, please log in or register
80613536
75
80613536  

I guys, I need some help. When I override an HLine object with the mouse, Mql4 draw a label that contain a text of index and level price of Hline. How can I read this text by an Custom Indicator, or an EA or a script?

Tank you for every help.

William Roeder
21815
William Roeder  

HLines have only one coordinate.

Perhaps you should read the manual. Read the object's price. ObjectGetDoubleENUM_OBJECT_PROPERTY_DOUBLE → OBJPROP_PRICE

80613536
75
80613536  

Hi William, if I don't know the name of object or object index how can I solve the ObjectGetDouble?

Tanks a lot.

Marco vd Heijden
Moderator
13015
Marco vd Heijden  

It also has a string value.

string text = ObjectGetString(0,"obj_name",OBJPROP_TEXT);
William Roeder
21815
William Roeder  
80613536: I don't know the name of object or object index how can I solve the ObjectGetDouble?

Start reading the documentation. ObjectsTotal and ObjectName

80613536
75
80613536  
Hi William, hi Marco, I don't understand your advices. If I don't know the Objetc Name nor the object index, I can with ObjectsTotal know the Max object index but by that I can only do a for cycle on all object index, but they are a lot and I search a alternative way.
William Roeder
21815
William Roeder  
80613536 I can only do a for cycle on all object index, but they are a lot and I search a alternative way.

There is no alternative. Go through the list, find the object you want, do what you want with it. Only you know the type, the naming pattern, etc.

Marco vd Heijden
Moderator
13015
Marco vd Heijden  
80613536:
Hi William, hi Marco, I don't understand your advices. If I don't know the Objetc Name nor the object index, I can with ObjectsTotal know the Max object index but by that I can only do a for cycle on all object index, but they are a lot and I search a alternative way.

What are you trying to do ? 

Is this ObjectName always the same ? 

How do you know you have the desired Object ? 

The hover pop up is the tooltip.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ScanObjects()
{
   int obj_total=ObjectsTotal(0);
   string name;
   string text;
   string tip;
   for(int i=0; i<obj_total; i++)
      {
         name = ObjectName(0,i);
         text = ObjectGetString(0,name,OBJPROP_TEXT);
         tip  = ObjectGetString(0,name,OBJPROP_TOOLTIP);
         Print(i," object: ",name," text: ",text," tip: ",tip);
      }
}
//+------------------------------------------------------------------+
To add comments, please log in or register