MQL4 Reference Object Functions

Object Functions

This is the group of functions intended for working with graphic objects relating to any specified chart. When working with objects on the current chart, a direct access is used, i.e. the existence of the specified object is pre-checked during the function call, and the error code is immediately returned in case of failure. When a function is used for the objects of a chart other than the current one, an asynchronous function call is used, during which no pre-checks are performed and the function is added to the queue of that chart as is.

Functions that set the properties of graphical objects, as well as the ObjectCreate() and ObjectMove() operations are actually used for sending commands to a chart. If these functions are executed successfully, the command is added to the queue of chart events. Visual changes in the properties of graphical objects are implemented upon handling of chart events from the queue.

That is why you should do not expect an immediate visual update of graphical objects after calling these functions. Generally, graphical objects on a chart are updated automatically by the terminal based on update events, such as a new quote arrival, chart window resizing, etc. Use the ChartRedraw() command to force the update of graphical objects.




Creates an object of the specified type in a specified chart


Returns the name of an object by its index in the objects list


Removes the object having the specified name


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


Searches for an object having the specified name


Returns the time value for the specified object price value


Returns the price value of an object for the specified time


Changes the coordinates of the specified object anchor point


Returns the number of objects of the specified type


Returns the double value of the corresponding object property


Returns the integer value of the corresponding object property


Returns the string value of the corresponding object property


Sets the value of the corresponding object property


Sets the value of the corresponding object property


Sets the value of the corresponding object property


Sets the font for displaying the text using drawing methods (Arial 20 used by default)


Transfers the text to the custom array (buffer) designed for creation of a graphical resource


Returns the string's width and height at the current font settings


Returns the object description


Returns the value of the specified object property


Returns the level description of a Fibonacci object


Calculates and returns bar index for the given price


Calculates and returns the price value for the specified bar


Changes the value of the specified object property


Sets a new description to a level of a Fibonacci object


Changes the object description


Returns the object type

Every graphical object should have a name unique within one chart, including its subwindows. Changing of a name of a graphic object generates two events: event of deletion of an object with the old name, and event of creation of an object with a new name.

After an object is created or an object property is modified it is recommended to call the ChartRedraw() function, which commands the client terminal to forcibly draw a chart (and all visible objects in it).


What's new in MQL5

MQL5 features more graphical objects, and the most unusual of them is OBJ_CHART(Chart) — you are able to insert such objects as symbol charts. If you complement OBJ_CHART with indicators and control panels handling custom events, a usual chart turns into a convenient analysis tool with the ability to quickly change symbols and timeframes in a single mouse click.

The properties of objects for managing program objects have been significantly expanded. Now you are able to set colors, move an object to the back or front, set the priority for intercepting keyboard and mouse events on a chart, as well as select an object or hide it from the list of visible ones. All this allows you to develop a graphical user interface of any complexity.