How to refernce a chart object

 

Thought this would be easy but can't find a solution


If - for example I have some objects on a chart then I want my EA to check for there existence then interrogate the details of the object.

If I draw - say 3 lines on a chart - Insert Hline - then I will have 3 lines withe names like Horizontal Line 12345.

I want to check and find say 5 x Horizontal Lines (Resistance Levels)  and then find the value of each and then write the information to file for that symbol.

The name of the object does not matter

Any help appreciated

 

You need the name of an object to get the information.

If you don't know names then check ObjectsTotal() and Objectname() functions.

This is sample code that lists objects on a chart:

   int obj_total=ObjectsTotal();
   PrintFormat("Total %d objects",obj_total);
   string name;
   for(int i=0;i<obj_total;i++)
     {
      name=ObjectName(i);
      PrintFormat("%d object: Object name - %s",i,name);
     }

 

If you have a name of an object(s) then check if object exists on a chart with ObjectFind() and if object exists you can obtain data via ObjectGet()ObjectGetDouble(), ObjectGetInteger() and ObjectGetString() functions.

 

Just what I thought I should be able to do but hadn't found / understood the parts.


Many thanks

Reason: