Download MetaTrader 5
MQL5 ReferenceObject FunctionsObjectsDeleteAll 


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



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


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


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


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

Updated: 2015.12.03