Documentation

The Chart Corner to Which an Object Is Attached

There is a number graphical objects, for which you can set the corner of a chart, relative to which coordinates are specified in pixels. These are the following types of objects (in brackets object type identifiers are specified):

  • Label (OBJ_LABEL);
  • Button (OBJ_BUTTON);
  • Chart (OBJ_CHART);
  • Bitmap Label (OBJ_BITMAP_LABEL);
  • Edit (OBJ_EDIT).

In order to specify the chart corner, from which X and Y coordinates will be measured in pixels, use ObjectSetInteger(chartID, name, OBJPROP_CORNER, chart_corner), where:

  • chartID - chart identifier;
  • name –  name of a graphical object;
  • OBJPROP_CORNER – property ID to specify the corner for binding;
  • chart_corner – the desired chart corner, can be one of the values of the ENUM_BASECORNER enumeration.

ENUM_BASE_CORNER

ID

Description

CORNER_LEFT_UPPER

Center of coordinates is in the upper left corner of the chart

CORNER_LEFT_LOWER

Center of coordinates is in the lower left corner of the chart

CORNER_RIGHT_LOWER

Center of coordinates is in the lower right corner of the chart

CORNER_RIGHT_UPPER

Center of coordinates is in the upper right corner of the chart

Example:

void CreateLabel(long   chart_id,
                 string name,
                 int    chart_corner,
                 string text_label,
                 int    x_ord,
                 int    y_ord)
  {
//---
   ObjectCreate(chart_id,name,OBJ_LABEL,0,0,0);
   ResetLastError();
   if(!ObjectSetInteger(chart_id,name,OBJPROP_CORNER,chart_corner))
      Print("Unable to set the angle to bind the object",
            name,", error code ",GetLastError());
   ObjectSetInteger(chart_id,name,OBJPROP_XDISTANCE,x_ord);
   ObjectSetInteger(chart_id,name,OBJPROP_YDISTANCE,y_ord);
   ObjectSetString(chart_id,name,OBJPROP_TEXT,text_label);
  }
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   int height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   int width=ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);
   string arrows[4]={"LEFT_UPPER","RIGHT_UPPER","RIGHT_LOWER","LEFT_LOWER"};
   CreateLabel(0,arrows[0],CORNER_LEFT_UPPER,"0",50,50);
   CreateLabel(0,arrows[1],CORNER_RIGHT_UPPER,"1",50,50);
   CreateLabel(0,arrows[2],CORNER_RIGHT_LOWER,"2",50,50);
   CreateLabel(0,arrows[3],CORNER_LEFT_LOWER,"3",50,50);
  }