How to delete all objects created by a custom indicator?

 

Alternatively, how do I delete all OBJ_VLINES with a certain string in their name?

If I do the following, only about half the matching lines get deleted. 

int obj_total=ObjectsTotal(); 
int result;
string name; 
   
   for(int i=0;i<obj_total;i++) 
    { 
     
     name = ObjectName(i);
     result = StringFind(name,substring);

     if(result > -1) 
         {
           ObjectDelete(name);    
         }
       
    }
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
mt4ski: If I do the following, only about half the matching lines get deleted. 
  1. Of course, it does.
  2. Simple fix, but since you were argumentative and arrogant last February, you were put on my do not help list.
 
William Roeder:
  1. Of course, it does.
  2. Simple fix, but since you were argumentative and arrogant last February, you were put on my do not help list.

Not everything is the programmer's fault. Sometimes bugs, glitches and hacking happens. Long is passed the time when you should have let go of your grudge. Get over yourself.

 
mt4ski:

Alternatively, how do I delete all OBJ_VLINES with a certain string in their name?

If I do the following, only about half the matching lines get deleted. 

void OnStart()
  {
//---
   int obj_total=ObjectsTotal();

   for(int i=0; i<obj_total; i++)
     {
      if((ObjectType(ObjectName(i))==OBJ_VLINE))  ObjectDelete(ObjectName(i)) ;
     }
  }
 
mt4ski:

Alternatively, how do I delete all OBJ_VLINES with a certain string in their name?

If I do the following, only about half the matching lines get deleted. 

int obj_total=ObjectsTotal(); 
int result;
string name; 
   
   for(int i=0;i<obj_total;i++) 
    { 
     
     name = ObjectName(i);
     result = StringFind(name,substring);

     if(result > -1) 
         {
           ObjectDelete(name);    
         }
       
    }

Mehmet Bastem:

void OnStart()
  {
//---
   int obj_total=ObjectsTotal();

   for(int i=0; i<obj_total; i++)
     {
      if((ObjectType(ObjectName(i))==OBJ_VLINE))  ObjectDelete(ObjectName(i)) ;
     }
  }


Always count down in the loops.

for(int i=ObjectsTotal()-1;i>=0;i--) 
 
mt4ski: Get over yourself.

Argumentative and arrogant again (4x) but Keith gave it to you.

 
Keith Watford:

Always count down in the loops.

Of course. Thanks.
William Roeder:

Argumentative and arrogant again (4x) but Keith gave it to you.


No I just pointed out the fact that you are still holding an old grudge. I would not have said anything if you did not raise this argument from the grave in the first place. Get over it, if only for your own benefit. At least just say nothing if you don't want to help.
Reason: