Scripts: CLEAR_CHART_ON_NAME_AND_TYPE

 

CLEAR_CHART_ON_NAME_AND_TYPE :

The script selectively clears the chart by the part of the name and/or by the type of the object.

Author: Aleksandr Pak ekr-ap@mail.ru

 

Very very nice and useful.

Thank you very much.

I've already made it in MQL5.

I can post it in codebase of MQL5. Are you ok with this?

Thanks anyway.

 

A more flexible version:

1. if user enters partial name and selects some types => script will delete all objects with those types and with that partial name

2. if user enters partial name but selects no types => script will delete all objects with that partial name

3. if user enters no partial name and selects some types => script will delete all objects with those types

4. if user enters no partial name and doesn't select any type => script will delete all objects

I find this version more intuitive.

this is just start() function:

int start()
  {
//----
   string s; 
   int i,j,k,_type;
   k=ObjectsTotal();
   bool typesSelected=false;
   for(j=0;j<24;j++) if(u[j]) typesSelected=true;
   
   if (StringLen(delete_on_Partial_name)!=0)
      if (typesSelected) //partial name entered and some types selected
        for (i=k-1;i>=0; i--) {//óäàëåíèå ïî òèïó//delete by type and partial name
            s=ObjectName(i);
            _type=ObjectType(s);
            if(_type>=0&&_type<=23)
                  for(j=0;j<24;j++)
                     if(u[_type] && StringFind(s,delete_on_Partial_name,0)>=0) ObjectDelete(s);
         } 
      else //partial name entered and no type selected
         for (i=k-1;i>=0; i--) {//óäàëÿåì ïàðòèþ//delete partial 
            s=ObjectName(i);
            if(StringFind(s,delete_on_Partial_name,0)>=0)ObjectDelete(s);
         }
   else 
      if (typesSelected) //no partial name entered and some types selected
         for (i=k-1;i>=0; i--) {//óäàëåíèå ïî òèïó//delete by type
            s=ObjectName(i);
            _type=ObjectType(s);
            if(_type>=0&&_type<=23)
                  for(j=0;j<24;j++)
                     if(u[_type]) ObjectDelete(s);
         }
      else //no partial name entered and no type selected  
         for (i=k-1;i>=0; i--) {//óäàëÿåì âñå//delte ALL
            s=ObjectName(i);
            ObjectDelete(s);
         }
   return(0);
}
Reason: