ObjectCreateAndSet - MetaTrader 5 Library - MT4/MT5 Resources




The attached *.mqh file contains functions for creating objects and changing object properties. It's especially useful to me when I need to quickly write some test code to create objects on the chart and/or change properties of existing objects.
Another file is a script with a usage example (create a text label, gradually rotate it 90 degrees, and change the text and its color along the way).
1. Function to create objects :
These functions are based on standard functions described in MQL5 Reference . Main differences from the corresponding standard functions:
List of functions that create objects:
Create a vertical line
Create a horizontal line
Create a trendline based on given coordinates
Arrow line creation
Creates a line with an arrow based on given coordinates
Create equidistant channels by given coordinates
Rectangle creation
Create a rectangle based on the given coordinates
Creates a triangle based on given coordinates
Create an ellipse based on given coordinates
Create OBJ_ARROW
Create text object
Create text labels
Create a button
Create a bitmap in the chart window
Bitmap label creation
Create a bitmap label object
Create editing object
Create an event object on the chart
Rectangular label creation
Create a rectangular label
2. Function to set object properties:
Use object set double(...) , object set integer(...) and object set string(...) without specifying modifiers:
Specify modifiers using ObjectSetDouble(...) , ObjectSetInteger(...) and ObjectSetString(...) :
Additional features:
You can use it as an include file or copy some of its functions into your source code.
If you choose the second way, I think it's better to use it as an include file first. Once all necessary function calls have been implemented, you can remove the include directives (#include ...).
The compiler then indicates which functions you need to copy from the include file.
Use as include file:
#includeThe attached script provides an example that includes this library.

Figure 1. The full name of the function in the tool tip after entering the first few letters

Figure 2. Parameters of function in tooltip
By the way, you can use the function list button on the meta-editor toolbar to quickly see a list of functions used in the current file:

Figure 3. Button to display a list of functions used in the file
When you press the button, a drop-down list appears. To go to a specific function, click its name in the list.

Figure 4. Pressing the button opens a list of functions in the file (helps to quickly go to a function)
Attachment download
📎 objectcreateandset.mqh (96.06 KB)
📎 test_labelcreate.mq5 (3.58 KB)
Source: MQL5 #13374
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •