EA Programming Tutorial Book of Chart Functions

2023/2/24 18:44:37  read(3)

 For the current chart related to a set of chart howtocopyforextradingst forex copy tradings forextradingsignals ObjectCreate  ObjectDelete  ObjectDescription  ObjectFind  ; ObjectGet  ObjectGetFiboDescription  ObjectGetShiftByValue  ObjectGetValueByShift   ObjectMove  ObjectName  ObjectsDeleteAll  ObjectSet  ObjectSetFiboDescription   ObjectSetText  ObjectsTotal  ObjectType  boolObjectCreate(stringname,inttype,intwindow,datetimetime1 doubleprice1,voidtime2,voidprice2,voidtime3,voidprice3) object created by the specified name, type and initial coordinates of the specified window count coordinates associated with the object can be from 1 to 3 object types if the function succeeds, the return value will be TRUE, otherwise, it will be FALSE get For detailed error information, cashback forex the GetLastError() function OBJ_LABEL type of object ignores the coordinates Use ObjectSet() to set the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE properties Note: child window chart (if the child window has indicators) number from 1 to the index of the presence of the main window for zero must pass the coordinates: time and price for example, OBJ_VLINE only objects need time, but must pass the price (any value) parameters: name - object unique name  type - object type it can be any value of the object type enumeration & nbsp;window - piece window will increase the index window index must be more than or equal to 0 and less than WindowsTotal()  time1 - the time part of the first point  price1 -& nbsp;the value part of the first point  time2 - the time part of the second point  price2 - the value part of the second point  time3 - the time part of the third point  nbsp; price3 - the value part of the third point   Example: //new text object  if(!ObjectCreate(text_object,OBJ_TEXT,0,D 2004.02.2012:30,1.0045))    {   Print(Error: Cannot create text! Code#,GetLastError());    return(0);    }  //new text label  if(!ObjectCreate( label_object,OBJ_LABEL,0,0,0))    {    Print(Error: Cannot create text! Code#,GetLastError());    return(0);    }  ObjectSet(label_object,OBJPROP_ XDISTANCE,200);  ObjectSet(label_object,OBJPROP_YDISTANCE,100);         boolObjectDelete( stringname)Delete the object has a specified name if the function succeeds, the return value will be TRUE, otherwise, it will be FALSE to get detailed error information, see GetLastError() function parameters: name - The name of the object deleted    Example: ObjectDelete(text_object);       stringObjectDescription(stringname) returns the object description for OBJ_TEXT and OBJ_LABEL type objects, these object text will return to get detailed error information, see GetLastError() function see ObjectSetText() function parameter:name - object name    example: // for file write down chart object    nbsp;int   handle,total;  stringobj_name,fname;   //file name  fname=objlist_+Symbol();& nbsp; handle=FileOpen(fname,FILE_CSV|FILE_WRITE);  if(handle!=false)    {     & nbsp;total=ObjectsTotal();    for(inti=-;i<total;i++)      {    {    ;     obj_name=ObjectName(i);            FileWrite(handle,Object+obj_ name+description=+ObjectDescription(obj_name));        }    FileClose(handle);& nbsp;    }     intObjectFind(stringname)Find the specified object name window index contains the object found if it fails, the return value will be -1 to get detailed error information, see GetLastError() function sub-window chart (if the sub-window with indicators) numbered from 1 the index of the main window is zero parameters: name - Find the object name    Example: if (ObjectFind(line_object2)! =win_idx)return(0); doubleObjectGet(stringname,intindex) function returns the specified objects property check error, see GetLastError() function see ObjectSet() function parameters:name -  object name  index - object property index it can be any  object property enumerated value   example:coloroldColor=ObjectGet(hline12,OBJPROP_COLOR);    nbsp;   stringObjectGetFiboDescription(stringname,intindex) function returns a plain description of the Fibonacci object a considerable number of Fibonacci levels depending on the type of object the maximum Fibonacci level is 32 to get detailed error information, see GetLastError() function see ObjectSetFiboDescription() function parameters: name - Fibonacci object name  index - Fibonacci index level (0-31)    Example:#include<stdlib.mqh>   ...   stringtext;  for(inti=0;i<32;i++)     {    text= ObjectGetFiboDescription(MyObjectName,i);    //---- check that the object is less than 32 horizontal lines    if(GetLastError()! =ERR_NO_ERROR)break;    Print(MyObjectName,level:,i,description:,text);     }       ;    intObjectGetShiftByValue(stringname,doublevalue) function calculates and returns the value given by the index column (moving the current relevant column) index column is calculated by applying linear equations to the first and second coordinates applied to trend lines and similar objects obtained For detailed error information, see GetLastError() function see ObjectGetValueByShift() function parameters: name - object name  value - price value    example : intshift=ObjectGetShiftByValue(MyTrendLine#123,1.34);        doubleObjectGetValueByShift( stringname,intshift) function calculates and returns the value of the specified bar (transferring the current associated bar) index bar by the first and second coordinates applied to the linear equation calculated for trend lines and similar objects to get detailed error information, see GetLastError() function see ObjectGetShiftByValue() function parameters :name - object name  shift - column index    Example: doubleprice=ObjectGetValueByShift(MyTrendLine# 123,11);      boolObjectMove(stringname,intpoint,datetimetime1,doubleprice1) function moves an object in the graph coordinates objects may have one to three depending on their type coordinates If the function succeeds, the return value will be TRUE, otherwise, it will be FALSE to get detailed error information, see GetLastError() function object coordinates of the starting number must be 0 parameters: name - object name   point - coordinate index ( 0-2)  time1 - new time value  price1 - new value   Example:ObjectMove(MyTrend,1,D2005.02.2512:30 ,1.2345); stringObjectName(intindex) in the object list with its index function to return the object name to get detailed error information, see GetLastError() function parameters:index - object index in the object list object index must exceed or equal to 0 and less than ObjectsTotal()   Example: int   obj_total=ObjectsTotal();  stringname;   for(inti=0;i<obj_total;i++)    {    name=ObjectName(i);    Print(i, ObjectName for +name);    }          intObjectsDeleteAll(voidwindow,voidtype) in the charts child window to delete all type object function returns the number of objects deleted to get detailed error information, see GetLastError() function Note: Sub-window chart (if the sub-window with indicators) numbered from 1 to the index of the presence of the main window is zero If the window index is wrong or the value is -1, objects will be deleted from the existing chart if the type value is equal to -1 or this parameter is wrong, all in the sub-window Specify the objects that will be deleted Parametric:window - Select the parametric object index window will be deleted must be more than or equal to -1 (EMPTY is the default) and less than WindowsTotal()type - Select the parametric object type that will be deleted it can be any object type with an enumerated value or EMPTY constant delete all object types Example: ObjectsDeleteAll(2,OBJ_HLINE);// remove all horizontal lines from the second subwindow  ObjectsDeleteAll(2);       ;        //Remove all objects from the second child window  ObjectsDeleteAll();               // Remove all objects from the chart        boolObjectSet(stringname,intindex,doublevalue) changes the value of the specified object property if If the function succeeds, the return value will be TRUE otherwise, it will be FALSE. Get detailed error information, see GetLastError() function see ObjectGet() function parameters: name - object name  index - object index value it can be any object property value listed  value - new property value   example: //movingthefirstcoordtothelastbartime   ObjectSet(MyTrend,OBJPROP_TIME1,Time[0]);  //settingthesecondfibolevel  ObjectSet(MyFibo,OBJPROP_FIRSTLEVEL+1, objectwillbeshownonlyon15minuteand1hourcharts  ObjectSet(MyObject,OBJPROP_FIRSTLEVEL+1, 1.234);  //settingobjectvisibility.objectwillbeshownonlyon15minuteand1hourcharts  ObjectSet(MyObject,OBJPROP_ TIMEFRAMES,OBJ_PERIOD_M15|OBJ_PERIOD_H1);       boolObjectSetFiboDescription(stringname,intindex, stringtext)The function assigns a new description to the Fibonacci level of the object a considerable number of Fibonacci levels depending on the type of object the maximum amount of Fibonacci levels is 32 to get detailed error information, see GetLastError() function parameters:name - Object name   index  - Fibonacci index level (0-31)  text - new level description   example:ObjectSetFiboDescription(MyFiboObject,2, Secondline); boolObjectSetText(stringname,stringtext,intfont_size,voidfont,voidtext_color)  Change object description for OBJ_TEXT and OBJ_ LABEL object description as the text of the chart display If the function succeeds, the returned value will be TRUE Otherwise, it is FALSE to get detailed error information, see GetLastError() function only font size, font name and text color parameters used for font_size, font_name and text_color objects for other type objects, these parameters are ignored see ObjectDescription() function parameters: name - object name  text - description object text  font_size -  font size points  font - font name  text_color - text color   Example:ObjectSetText(text_object, Helloworld!,10,TimesNewRoman,Green);       intObjectsTotal(voidtype) in the chart to return the specified object type total parametric:type - choose the parametric will count the type of objects it can be any value of the object type enumeration or EMPTY constant calculate all types of objects example: int   obj_total=ObjectsTotal();   stringname;  for (inti=0;i<obj_total;i++)    {    name=ObjectName(i);    Print(i,for # the object name,i,is+name);     }      intObjectType(stringname) function returns the object type value to get detailed error information, see GetLastError () function parameters:name - Object name    Example:if(ObjectType(line_object2)! =OBJ_HLINE)return(0);