Find ObjectType

 

How to filter ObjectName with ObjectType

string  ObjectName( 
   long  chart_id,           // chart identifier 
   int   pos,                // number in the list of objects 
   int   sub_window=-1,      // window index 
   int   type=-1             // object type 
   );

If Object type is OBJ_HLINE

How can i get all objects in chart except OBJ_HLINE

 
Arpit T:

How to filter ObjectName with ObjectType

If Object type is OBJ_HLINE

How can i get all objects in chart except OBJ_HLINE

There may be a better way, but I set a prefix so all common objects can be identified together.

For example all my position objects the name is always prefixed with "#P", so if I can easily delete all positions objects with this string prefix.

int  ObjectsDeleteAll( 
   long           chart_id,   // chart ID 
   const string     prefix,   // prefix in object name 
   int       sub_window=-1,   // window index 
   int      object_type=-1    // object type 
   );

You could apply the same approach and prefix all OBJ_HLINE objects with a common prefix - that way you have a way of knowing what type of object you are dealing with via your own naming convention

 
Arpit T: How can i get all objects in chart except OBJ_HLINE

Loop through all objects. Skip HLINEs.

for(int i=ObjectsTotal(0)-1; i >= 0; --i){
   string  n = ObjectName(0,i);
   if( ObjectGetInteger(0, n, OBJPROP_TYPE) == OBJ_HLINE) continue;
   ⋮ // got all objects in chart except OBJ_HLINE
}