int total=ObjectsTotal(); for(int i=0;i<total;i++) { if(StringCompare(ObjectDescription(ObjectName(i)),the_description)==0) { ObjectDelete(ChartID(),ObjectName(i)); break; } }
If you're going to be deleting things from within a loop, you'll need to count down (not up).
You must count down when closing/deleting in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forum
(Also applies to deleting multiple objects)
So, would it be like this?
int i; int totalobjects = ObjectsTotal(); for(i=totalobjects-1;i>=0;i--) { if(StringCompare(ObjectDescription(ObjectName(i)),"delete-me")==0) { ObjectDelete(ChartID(),ObjectName(i)); break; } }
gviali:
Yes,when counting down it would be like that.
So, would it be like this?

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys, I couldn't find here in the forum or documentation if is it possible to delete an object by getting his description only instead of the the name.
The application is to delete that Arrow object created by any EA when a position is opened as soon as it is created. I tought about insert this ObjectDelete function right above the OrderSend, so, as soon as the order is triggered, the delete function is triggered with, and instantly delete the object.
So, is it possible?
Thanks in advance.