Download MetaTrader 5

Scripts: CLEAR_CHART_ON_NAME_AND_TYPE

To add comments, please log in or register
What is a social trading? Read the article to find that out!
MetaQuotes Software Corp.
Moderator
181359
MetaQuotes Software Corp. 2008.11.09 08:30 

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

Mihai Ionescu
1301
Mihai Ionescu 2010.08.16 15:07  

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.

Mihai Ionescu
1301
Mihai Ionescu 2010.08.16 17:35  

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);
}
To add comments, please log in or register