MQL4 Reference Object Functions ObjectFind

ObjectFind

The function searches for an object having the specified name. There are two variants of the function:

int  ObjectFind(
   long     chart_id,     // chart ID
   string   object_name   // object name
   );

The function searches the object with the specified name:

int  ObjectFind(
   string   object_name   // object name
   );

Parameters

chart_id

[in]  Chart identifier.

object_name

[in]  The name of the object to find.

Return Value

If successful the function returns the number of the subwindow (0 means the main window of the chart), in which the object is found. If the object is not found, the function returns a negative number. To read more about the error call GetLastError().

Note

The chart sub-windows (if there are sub-windows with indicators in the chart) are numbered starting from 1. The chart main window always exists and has the 0 index.

Example:

  if(ObjectFind(0,"line_object2")!=win_idx) return(0);