- Object types and features of specifying their coordinates
- Time and price bound objects
- Objects bound to screen coordinates
- Creating objects
- Deleting objects
- Finding objects
- Overview of object property access functions
- Main object properties
- Price and time coordinates
- Anchor window corner and screen coordinates
- Defining anchor point on the object
- Managing the object state
- Priority of objects (Z-Order)
- Object display settings: color, style, and frame
- Font settings
- Rotating text at an arbitrary angle
- Determining object width and height
- Visibility of objects in the context of timeframes
- Assigning a character code to a label
- Ray properties for objects with straight lines
- Managing object pressed state
- Adjusting images in bitmap objects
- Cropping (outputting part) of an image
- Input field properties: alignment and read-only
- Standard deviation channel width
- Setting levels in level objects
- Additional properties of Gann, Fibonacci, and Elliot objects
- Chart object
- Moving objects
- Getting time or price at the specified line points
Main object properties
All objects have some universal attributes. The main ones are listed in the following table. We will see other general special-purpose properties later (see the Object state management, Z-order, and Visibility of objects in timeframe context sections).
Identifier |
Description |
Type |
---|---|---|
OBJPROP_NAME |
Object name |
string |
OBJPROP_TYPE |
Object type (r/o) |
ENUM_OBJECT |
OBJPROP_CREATETIME |
Object creation time (r/o) |
datetime |
OBJPROP_TEXT |
Description of the object (text contained in the object) |
string |
OBJPROP_TOOLTIP |
Mouseover tooltip text |
string |
The OBJPROP_NAME property is an object identifier. Editing it is equivalent to deleting the old object and creating a new one.
For some types of objects capable of displaying text (such as labels or buttons), the OBJPROP_TEXT property is always displayed directly on the chart, inside the object. For other objects (for example, lines), this property contains a description that is displayed on the chart next to the object and only if the "Show object descriptions option" is enabled in the chart settings. In either case, OBJPROP_TEXT is displayed in the tooltip.
The OBJPROP_CREATETIME property exists only until the end of the current session and is not written to chr files.
You can change the name of an object programmatically or manually (in the object's properties dialog), while its creation time will remain the same. Looking ahead, we note that programmatic renaming does not cause any events about objects on the chart. As we are about to learn in the next chapter, manual renaming triggers three events:
- deleting an object under the old name (CHARTEVENT_OBJECT_DELETE),
- creating an object under a new name (CHARTEVENT_OBJECT_CREATE) and
- modification of a new object (CHARTEVENT_OBJECT_CHANGE).
If the OBJPROP_TOOLTIP property is not set, a tooltip is displayed for the object, automatically generated by the terminal. To disable the tooltip, set its value to "\n" (line feed).
Let's adapt the ObjectFinder.mq5 script from the Finding objects section to log all the above properties of objects on the current chart. Let's name the new script as ObjectListing.mq5.
At the very beginning of OnStart, we will create or modify a vertical straight line located on the last bar (at the moment the script is launched). If there is an option to show object descriptions in the chart settings, then we will see the "Latest Bar At The Moment" text along the right vertical line.
void OnStart()
|
Next, in a loop through the subwindows, we will query all objects up to ObjectsTotal and their main properties.
int count = 0;
|
We get the following entries in the log.
Window 0
|
A zero OBJPROP_CREATETIME value (1970.01.01 00:00) means that the object was not created during the current session, but earlier.