Skip to content

Object Properties

Object Properties

Graphical objects can have various properties depending on the object type. 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):

ObjectIDX/YWidth/HeightDate/PriceOBJPROP_CORNEROBJPROP_ANCHOROBJPROP_ANGLE
TextOBJ_TEXTYesYesYes
LabelOBJ_LABELYesYes (read only)YesYesYes
ButtonOBJ_BUTTONYesYesYes
BitmapOBJ_BITMAPYes (read only)YesYes
Bitmap LabelOBJ_BITMAP_LABELYesYes (read only)YesYes
EditOBJ_EDITYesYesYes
Rectangle LabelOBJ_RECTANGLE_LABELYesYesYes

The following designations are used in the table:

  • X/Y – coordinates of anchor points specified in pixels relative to a chart corner;
  • Width/Height – objects have width and height. For “read only”, the width and height values are calculated only once the object is rendered on chart;
  • Date/Price – anchor point coordinates are specified using the date and price values;
  • OBJPROP_CORNER – defines the chart corner relative to which the anchor point coordinates are specified. Can be one of the 4 values of the ENUM_BASE_CORNER enumeration;
  • OBJPROP_ANCHOR – defines the anchor point in object itself and can be one of the 9 values of the ENUM_ANCHOR_POINT enumeration. Coordinates in pixels are specified from this very point to selected chart corner;
  • OBJPROP_ANGLE – defines the object rotation angle counterclockwise.

Object value index used with ObjectGet() and ObjectSet() functions. It can be any of the following values:

IDValueTypeDescription
OBJPROP_TIME10datetimeDatetime value to set/get first coordinate time part
OBJPROP_PRICE11doubleDouble value to set/get first coordinate price part
OBJPROP_TIME22datetimeDatetime value to set/get second coordinate time part
OBJPROP_PRICE23doubleDouble value to set/get second coordinate price part
OBJPROP_TIME34datetimeDatetime value to set/get third coordinate time part
OBJPROP_PRICE35doubleDouble value to set/get third coordinate price part
OBJPROP_COLOR6colorColor value to set/get object color
OBJPROP_STYLE7intValue is one of STYLE_SOLID, STYLE_DASH, STYLE_DOT, STYLE_DASHDOT, STYLE_DASHDOTDOT constants to set/get object line style
OBJPROP_WIDTH8intInteger value to set/get object line width. Can be from 1 to 5
OBJPROP_BACK9boolBoolean value to set/get background drawing flag for object
OBJPROP_RAY10boolBoolean value to set/get ray flag of object.
OBJPROP_ELLIPSE11boolBoolean value to set/get ellipse flag for fibo arcs
OBJPROP_SCALE12doubleDouble value to set/get scale object property
OBJPROP_ANGLE13doubleDouble value to set/get angle object property in degrees
OBJPROP_ARROWCODE14ucharInteger value or arrow enumeration to set/get arrow code object property
OBJPROP_TIMEFRAMES15intValue can be one or combination (bitwise addition) of object visibility constants to set/get timeframe object property
OBJPROP_DEVIATION16doubleDouble value to set/get deviation property for Standard deviation objects
OBJPROP_FONTSIZE100intInteger value to set/get font size for text objects
OBJPROP_CORNER101intInteger value to set/get anchor corner property for label objects. Must be from 0-3.
OBJPROP_XDISTANCE102intInteger value to set/get anchor X distance object property in pixels (see note)
OBJPROP_YDISTANCE103intInteger value is to set/get anchor Y distance object property in pixels (see note)
OBJPROP_FIBOLEVELS200intInteger value to set/get Fibonacci object level count. Can be from 0 to 32
OBJPROP_LEVELCOLOR201colorColor value to set/get object level line color
OBJPROP_LEVELSTYLE202intValue is one of STYLE_SOLID, STYLE_DASH, STYLE_DOT, STYLE_DASHDOT, STYLE_DASHDOTDOT constants to set/get object level line style
OBJPROP_LEVELWIDTH203intInteger value to set/get object level line width. Can be from 1 to 5
OBJPROP_FIRSTLEVEL+n210+nintInteger value to set/get the value of Fibonacci object level with index n. Index n can be from 0 (number of levels -1), but not larger than 31

Every graphical object in a price chart has a certain set of properties. Values of object properties are set up and received by corresponding functions for working with graphical objects. For each object type there is its own set of properties. Here all possible values from the ENUM_OBJECT_PROPERTY enumeration family are listed. Some properties require clarification, such as the level number for the Fibonacci extension object. In such cases it is necessary to specify the value of the modifier parameter in the functions of ObjectSet…() and ObjectGet…().

For functions ObjectSetInteger() and ObjectGetInteger()

ENUM_OBJECT_PROPERTY_INTEGER

IdentifierDescriptionProperty Type
OBJPROP_COLORColorcolor
OBJPROP_STYLEStyleENUM_LINE_STYLE
OBJPROP_WIDTHLine thicknessint
OBJPROP_BACKObject in the backgroundbool
OBJPROP_ZORDERPriority of a graphical object for receiving events of clicking on a chart (CHARTEVENT_CLICK). The default zero value is set when creating an object; the priority can be increased if necessary. When objects are placed one atop another, only one of them with the highest priority will receive the CHARTEVENT_CLICK event.long
OBJPROP_HIDDENProhibit showing of the name of a graphical object in the list of objects from the terminal menu “Charts” - “Objects” - “List of objects”. The true value allows to hide an object from the list. By default, true is set to the objects that display calendar events, trading history and to the objects created from MQL4 programs. To see such graphical objects and access their properties, click on the “All” button in the “List of objects” window.bool
OBJPROP_SELECTEDObject is selectedbool
OBJPROP_READONLYAbility to edit text in the Edit objectbool
OBJPROP_TYPEObject typeENUM_OBJECT r/o
OBJPROP_TIMETime coordinatedatetime modifier=number of anchor point
OBJPROP_SELECTABLEObject availabilitybool
OBJPROP_CREATETIMETime of object creationdatetime r/o
OBJPROP_LEVELSNumber of levelsint
OBJPROP_LEVELCOLORColor of the line-levelcolor modifier=level number
OBJPROP_LEVELSTYLEStyle of the line-levelENUM_LINE_STYLE modifier=level number
OBJPROP_LEVELWIDTHThickness of the line-levelint modifier=level number
OBJPROP_ALIGNHorizontal text alignment in the “Edit” object (OBJ_EDIT)ENUM_ALIGN_MODE
OBJPROP_FONTSIZEFont sizeint
OBJPROP_RAY_RIGHTRay goes to the rightbool
OBJPROP_ELLIPSEShowing the full ellipse of the Fibonacci Arc object (OBJ_FIBOARC)bool
OBJPROP_ARROWCODEArrow code for the Arrow objectuchar
OBJPROP_TIMEFRAMESVisibility of an object at timeframesset of flags flags
OBJPROP_ANCHORLocation of the anchor point of a graphical objectENUM_ARROW_ANCHOR (for OBJ_ARROW),ENUM_ANCHOR_POINT (for OBJ_LABEL, OBJ_BITMAP_LABEL and OBJ_TEXT)
OBJPROP_XDISTANCEThe distance in pixels along the X axis from the binding corner (see note)int
OBJPROP_YDISTANCEThe distance in pixels along the Y axis from the binding corner (see note)int
OBJPROP_DRAWLINESDisplaying lines for marking the Elliott Wavebool
OBJPROP_STATEButton state (pressed / depressed)bool
OBJPROP_XSIZEThe object’s width along the X axis in pixels. Specified for OBJ_LABEL (read only), OBJ_BUTTON, OBJ_BITMAP, OBJ_BITMAP_LABEL, OBJ_EDIT, OBJ_RECTANGLE_LABEL objects.int
OBJPROP_YSIZEThe object’s height along the Y axis in pixels. Specified for OBJ_LABEL (read only), OBJ_BUTTON, OBJ_BITMAP, OBJ_BITMAP_LABEL, OBJ_EDIT, OBJ_RECTANGLE_LABEL objects.int
OBJPROP_XOFFSETThe X coordinate of the upper left corner of the rectangular visible area in the graphical objects “Bitmap Label” and “Bitmap” (OBJ_BITMAP_LABEL and OBJ_BITMAP). The value is set in pixels relative to the upper left corner of the original image.int
OBJPROP_YOFFSETThe Y coordinate of the upper left corner of the rectangular visible area in the graphical objects “Bitmap Label” and “Bitmap” (OBJ_BITMAP_LABEL and OBJ_BITMAP). The value is set in pixels relative to the upper left corner of the original image.int
OBJPROP_BGCOLORThe background color for OBJ_EDIT, OBJ_BUTTON, OBJ_RECTANGLE_LABELcolor
OBJPROP_CORNERThe corner of the chart to link a graphical objectENUM_BASE_CORNER
OBJPROP_BORDER_TYPEBorder type for the “Rectangle label” objectENUM_BORDER_TYPE
OBJPROP_BORDER_COLORBorder color for the OBJ_EDIT and OBJ_BUTTON objectscolor

For objects OBJ_BITMAP_LABEL and OBJ_BITMAP, a special mode of image display can be set programmatically. 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 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 and OBJ_EDIT, 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 functions ObjectSetDouble() and ObjectGetDouble()

ENUM_OBJECT_PROPERTY_DOUBLE

IdentifierDescriptionProperty Type
OBJPROP_PRICEPrice coordinatedouble modifier=number of anchor point
OBJPROP_LEVELVALUELevel valuedouble modifier=level number
OBJPROP_SCALEScale (properties of Gann objects, Fibonacci Arcs and Ellipse)double
OBJPROP_ANGLEAngle. For the objects with no angle specified, created from a program, the value is equal to EMPTY_VALUEdouble
OBJPROP_DEVIATIONDeviation for the Standard Deviation Channeldouble

For functions ObjectSetString() and ObjectGetString()

ENUM_OBJECT_PROPERTY_STRING

IdentifierDescriptionProperty Type
OBJPROP_NAMEObject namestring
OBJPROP_TEXTDescription of the object (the text contained in the object)string
OBJPROP_TOOLTIPThe text of a tooltip. If the property is not set, then the tooltip generated automatically by the terminal is shown. A tooltip can be disabled by setting the “\n” (line feed) value to itstring
OBJPROP_LEVELTEXTLevel descriptionstring modifier=level number
OBJPROP_FONTFontstring
OBJPROP_BMPFILEThe name of BMP-file for Bitmap Label. See also Resourcesstring modifier: 0-state ON, 1-state OFF
OBJPROP_SYMBOLSymbol for the Chart objectstring

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

IdentifierDescription
BORDER_FLATFlat form
BORDER_RAISEDProminent form
BORDER_SUNKENConcave 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

IdentifierDescription
ALIGN_LEFTLeft alignment
ALIGN_CENTERCentered (only for the Edit object)
ALIGN_RIGHTRight alignment

Example:

#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);
     }
  }
Last updated on