Error - ambiguous call to the overloaded

 

Dear 

I wrote a code below to delete all object match with object name

void DeleteObject(string OJ_Name)
{
   string OJ; bool is_Delete;
   for (int i = ObjectsTotal(0)-1; i >=0; i--) {
      OJ = ObjectName(0,i);
      if (StringFind(OJ, OJ_Name) >= 0) {
         is_Delete = ObjectDelete(0,OJ);
      }
   } 
}

Some time it compile ok some it give error and want to not compile


But as my knowledge code doesn't have any problem. 

 
Mohammad Ali: I wrote a code below to delete all object match with object name

Some time it compile ok some it give error and want to not compile

But as my knowledge code doesn't have any problem. 

From the error, I assume you are compiling under MQL4 because there are two variants on using the OrdersTotal() function, so you will have to qualify it and use one of the two alternatives:

   ...
ObjectsTotal( (long) 0 )  // Make it a long and not an int
   ...
ObjectsTotal( 0, -1, -1 ) // Or add the extra parameters
   ...
ObjectsTotal()            // Or just use the other variant
   ...

ObjectsTotal

( https://www.mql5.com/en/docs/objects/objectstotal )

The function returns the number of objects of the specified type in the specified chart. There are two variants of the function:

int  ObjectsTotal(
   long  chart_id,          // chart identifier
   int   sub_window=-1,     // window index
   int   type=-1            // object type
   );

The function returns the number of objects of the specified type:

int  ObjectsTotal(
   int    type=EMPTY        // object type
   );


ObjectsTotal - Object Functions - MQL4 Reference
ObjectsTotal - Object Functions - MQL4 Reference
  • docs.mql4.com
When this function is used on the current chart, this chart is accessed directly, while in order to receive the properties of an object on a different chart, a synchronous call is used. The synchronous...
 
Documentation on MQL5: Object Functions / ObjectsDeleteAll
Documentation on MQL5: Object Functions / ObjectsDeleteAll
  • www.mql5.com
[in]  Prefix in object names. All objects whose names start with this set of characters will be removed from chart. You can specify prefix as 'name' or 'name*' – both variants will work the same. If an empty string is specified as the prefix, objects with all possible names will be removed. The function uses a synchronous call...
Reason: