Well, I use this within my functions to create new Objects:
string nme = "..."; if(ObjectFind(0,nme) >= 0) ObjectDelete(0,nme); ResetLastError(); // delete existing object. ...
Read the ref. for ObjectFind(): place the cursor in the MQ editor on the function and press F1:
"a negative number" - not necessarily -1.

- www.mql5.com
I also used < 0
if( ObjectFind(0,"GapSell"+IntegerToString(s)) < 0)
The real problem, however, is not the code but the MT4/5 makes it difficult to handle so many objects in the graph because they are asynchronous functions
Hi guys, I have a problem with rectangles...
I have a for loop with which I draw many rectangles on the chart,(15/20), and agni new candle I want to update the anchor point and not a problem this.
How can I solve it?
15/20 rectangles? It's not a lot
Don't keep coping code. if( ObjectFind(0,"GapSell"+IntegerToString(s)) == -1){ Rettangolo("GapSell"+IntegerToString(s),ColoreDX,time1,Price1,time2,Price2);
Write it once, so it's readable and understandable. string name = "GapSell"+IntegerToString(s); if( ObjectFind(0,name) == -1){ Rettangolo(name,ColoreDX,time1,Price1,time2,Price2);
-
What is "s"? Use readable, understandable variable names. It can't be an as-series index, as they are not unique. As soon as a new bar starts, you will be trying to create a new name (e.g., “name0”), same, existing, previous, name (e.g., “name0” now on bar one.)
Use time (as int) or a non-series index:
#define SERIES(I) (Bars - 1 - I) // As-series to non-series or back.
Don't keep coping code. Write it once, so it's readable and understandable. -
What is "s"? Use readable, understandable variable names. It can't be an as-series index, as they are not unique. As soon as a new bar starts, you will be trying to create a new name (e.g., “name0”), same, existing, previous, name (e.g., “name0” now on bar one.)
Use time (as int) or a non-series index:

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys, I have a problem with rectangles...
I have a for loop with which I draw many rectangles on the chart,(15/20), and agni new candle I want to update the anchor point and not a problem this.
But I notice that the indicator fails to update all rectangles making a lot of confusion in the chart.
I've tried different solutions by deleting the rectangle and rewriting it or moving it or changing the time setting..
it all works at the code level manel graph it's like the MT4/MT5 can't handle all these drawings to do.
How can I solve it?