MQL4 Reference Object Functions ObjectsDeleteAll

ObjectsDeleteAll

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

int  ObjectsDeleteAll(
   long   chart_id,           // chart ID
   int    sub_window=EMPTY,   // window index
   int    object_type=EMPTY   // object type
   );

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

int  ObjectsDeleteAll(
   int    sub_window=EMPTY,   // window index
   int    object_type=EMPTY   // 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=EMPTY,   // window index
   int    object_type=EMPTY   // object type
   );

Parameters

chart_id

[in]  Chart identifier.

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=EMPTY

[in] Number of the chart window. Must be greater or equal to -1 (-1 mean all subwindows, 0 means the main chart window) and less than WindowsTotal().

object_type=EMPTY

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

Return Value

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

Example:

  ObjectsDeleteAll(2, OBJ_HLINE); // delete all horizontal lines from the 2nd subwindow
  ObjectsDeleteAll(2);            // delete all objects from the 2nd subwindow
  ObjectsDeleteAll();             // delete all objects from chart.