Professional Documents
Culture Documents
Object Properties: MQL5 Reference / Constants, Enumerations and Structures / Objects Constants / Object Properties
Object Properties: MQL5 Reference / Constants, Enumerations and Structures / Objects Constants / Object Properties
MQL5 Reference / Constants, Enumerations and Structures / Objects Constants / Object Properties
Object Properties
Graphical objects can have various properties depending on the object type. Values of object properties are set up and received by corresponding
functions for working with graphical objects.
All objects used in technical analysis are bound to the time and price coordinates: trendline, channels, Fibonacci tools, etc. But there is a number of
auxiliary objects intended to improve the user interface that are bound to the always visible part of a chart (main chart windows or indicator
subwindows):
mk:@MSITStore:c:\users\np\appdata\roaming\metaquotes\terminal\help\mql5.chm::/e... 11/27/2018
Object Properties Page 2 of 4
When using chart operations for the "Chart" object (OBJ_CHART), the following limitations are imposed:
• It cannot be closed using ChartClose();
• Symbol/period cannot be changed using the ChartSetSymbolPeriod() function;
• The following properties are ineffective CHART_SCALE, CHART_BRING_TO_TOP, CHART_SHOW_DATE_SCALE and CHART_SHOW_PRICE_SCALE
(ENUM_CHART_PROPERTY_INTEGER).
You can set a special mode of image display for OBJ_BITMAP_LABEL and OBJ_BITMAP objects. In this mode, only part of an original image (at which a
rectangular visible area is applied) is displayed, while the rest of the image becomes invisible. The size of this area should be set using the properties
mk:@MSITStore:c:\users\np\appdata\roaming\metaquotes\terminal\help\mql5.chm::/e... 11/27/2018
Object Properties Page 3 of 4
OBJPROP_XSIZE and OBJPROP_YSIZE. The visible area can be "moved" only within the original image using the properties OBJPROP_XOFFSET and
OBJPROP_YOFFSET.
For the fixed-sized objects: OBJ_BUTTON, OBJ_RECTANGLE_LABEL, OBJ_EDIT and OBJ_CHART, properties OBJPROP_XDISTANCE and
OBJPROP_YDISTANCE set the position of the top left point of the object relative to the chart corner (OBJPROP_CORNER), from which the X and Y
coordinates will be counted in pixels.
For the OBJ_RECTANGLE_LABEL object ("Rectangle label") one of the three design modes can be set, to which the following values of
ENUM_BORDER_TYPE correspond.
ENUM_BORDER_TYPE
Identifier Description
BORDER_FLAT Flat form
BORDER_RAISED Prominent form
BORDER_SUNKEN Concave form
For the OBJ_EDIT object ("Edit") and for the ChartScreenShot() function, you can specify the horizontal alignment type using the values of the
ENUM_ALIGN_MODE enumeration.
ENUM_ALIGN_MODE
Identifier Description
ALIGN_LEFT Left alignment
ALIGN_CENTER Centered (only for the Edit object)
ALIGN_RIGHT Right alignment
Example:
mk:@MSITStore:c:\users\np\appdata\roaming\metaquotes\terminal\help\mql5.chm::/e... 11/27/2018
Object Properties Page 4 of 4
#define UP "\x0431"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
string label_name="my_OBJ_LABEL_object";
if(ObjectFind(0,label_name)<0)
{
Print("Object ",label_name," not found. Error code = ",GetLastError());
//--- create Label object
ObjectCreate(0,label_name,OBJ_LABEL,0,0,0);
//--- set X coordinate
ObjectSetInteger(0,label_name,OBJPROP_XDISTANCE,200);
//--- set Y coordinate
ObjectSetInteger(0,label_name,OBJPROP_YDISTANCE,300);
//--- define text color
ObjectSetInteger(0,label_name,OBJPROP_COLOR,clrWhite);
//--- define text for object Label
ObjectSetString(0,label_name,OBJPROP_TEXT,UP);
//--- define font
ObjectSetString(0,label_name,OBJPROP_FONT,"Wingdings");
//--- define font size
ObjectSetInteger(0,label_name,OBJPROP_FONTSIZE,10);
//--- 45 degrees rotation clockwise
ObjectSetDouble(0,label_name,OBJPROP_ANGLE,-45);
//--- disable for mouse selecting
ObjectSetInteger(0,label_name,OBJPROP_SELECTABLE,false);
//--- draw it on the chart
ChartRedraw(0);
}
}
mk:@MSITStore:c:\users\np\appdata\roaming\metaquotes\terminal\help\mql5.chm::/e... 11/27/2018