All objects can't be deleted

To add comments, please log in or register
Cezarion
51
Cezarion  

Hello,

I have problem when I want to delete all objects from chart with names begining at "AT_".

Only several of them are deleted, always the same are leving on the chart. I cheked names, all are correct and all objects are finded but not deleted.

Any idea?

void DeleteAllObjects()
 {
  
  int obj_total=ObjectsTotal(); 
  string name; 
  
  for(int i=0;i<obj_total;i++) 
    { 
     name = ObjectName(i);

     if(StringFind(name,"AP_")>=0)
       {
         Print(name);
         ObjectDelete(
0,name);
       }
    }
    
  return; 
 }
Kenneth Parling
8780
Kenneth Parling  
GiovanniImperiale:

Hello,

I have problem when I want to delete all objects from chart with names begining at "AT_".

Only several of them are deleted, always the same are leving on the chart. I cheked names, all are correct and all objects are finded but not deleted.

Any idea?

ObjectDelete("AT_");

or

ObjectsDeleteAll();

This might work.....

William Roeder
20233
William Roeder  
GiovanniImperiale: Only several of them are deleted,
  1. Kenneth has already given you the simple method.
  2. The reason your code doesn't work is that you are counting up.
    you can simply count down, in a position loop, and you won't miss orders. Get in the habit of always counting down.
              Loops and Closing or Deleting Orders - MQL4 programming forum
Cezarion
51
Cezarion  

Hello,

Yes, 

ObjectsDeleteAll(); 

can be use but I want to avoid deleting objects which are the part of second panel on chart. That's why I used:

if(StringFind(name,"AP_")>=0)

But with Roedger advaise it works.

Thank you!

Mladen Rakic
160518
Mladen Rakic  
GiovanniImperiale:

Hello,

Yes, 

ObjectsDeleteAll(); 

can be use but I want to avoid deleting objects which are the part of second panel on chart. That's why I used:

But with Roedger advaise it works.

Thank you!

ObjectsDeleteAll(0,"AT_);

To add comments, please log in or register