MQL4 - automated forex trading   /  

Documentation

ODL Securities

MQL4 Reference  Object functions  ObjectCreate

 
bool ObjectCreate( string name, int type, int window, datetime time1, double price1, datetime time2=0, double price2=0, datetime time3=0, double price3=0)
Creation of an object with the specified name, type and initial coordinates in the specified window. Count of coordinates related to the object can be from 1 to 3 depending on the object type. If the function succeeds, the returned value will be TRUE. Otherwise, it will be FALSE. To get the detailed error information, one has to call the GetLastError() function. Objects of the OBJ_LABEL type ignore the coordinates. Use the function of ObjectSet() to set up the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties.
Notes: The chart sub-windows (if there are sub-windows with indicators in the chart) are numbered starting from 1. The chart main window always exists and has the 0 index.
Coordinates must be passed in pairs: time and price. For example, the OBJ_VLINE object needs only time, but price (any value) must be passed, as well.
Parameters:
name   -   Object unique name.
type   -   Object type. It can be any of the Object type enumeration values.
window   -   Index of the window where the object will be added. Window index must exceed or equal to 0 and be less than WindowsTotal().
time1   -   Time part of the first point.
price1   -   Price part of the first point.
time2   -   Time part of the second point.
price2   -   Price part of the second point.
time3   -   Time part of the third point.
price3   -   Price part of the third point.
Sample:
  // new text object
  if(!ObjectCreate("text_object", OBJ_TEXT, 0, D'2004.02.20 12:30', 1.0045))
    {
     Print("error: can't create text_object! code #",GetLastError());
     return(0);
    }
  // new label object
  if(!ObjectCreate("label_object", OBJ_LABEL, 0, 0, 0))
    {
     Print("error: can't create label_object! code #",GetLastError());
     return(0);
    }
  ObjectSet("label_object", OBJPROP_XDISTANCE, 200);
  ObjectSet("label_object", OBJPROP_YDISTANCE, 100);