ObjectFind

The function searches for an object with the specified name in the chart with the specified ID.

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

Parameters

chart_id

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

name

[in]  The name of the searched object.

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

When an object is renamed, two events are formed simultaneously. These events can be handled in an Expert Advisor or indicator by the OnChartEvent() function:

  • an event of deletion of an object with the old name;
  • an event of creation of an object with a new name.