MQL5 ReferenceObject FunctionsObjectsDeleteAll 

ObjectsDeleteAll

Removes all objects from the specified chart, specified chart subwindow, of the specified type.

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

Removes all objects of the specified type using prefix in object names.

int  ObjectsDeleteAll(
   long           chart_id,   // chart ID
   const string     prefix,   // prefix in object name
   int       sub_window=-1,   // window index
   int      object_type=-1    // object type
   );

Parameters

chart_id

[in]  Chart identifier. 0 means the current chart.

prefix

[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.

sub_window=-1

[in] Number of the chart subwindow. 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.

type=-1

[in]  Type of the object. The value can be one of the values of the ENUM_OBJECT enumeration. -1 means all types.

Return Value

Returns the number of deleted objects. To read more about the error call GetLastError().

Note

The function uses a synchronous call, which means that the function waits for the execution of all commands that have been enqueued for this chart prior to its call, that is why this function can be time consuming. This feature should be taken into account when working with a large number of objects on a chart.