找回密码
 立即注册

MQL4>MQL5:对象函数

2024-5-1 21:14| 发布者: admin| 查看: 275| 评论: 0|来自: 文章来源MQL5官网

摘要: 文章来源MQL5官网
 
MQL4
 MQL5说明
bool ObjectCreate(string name,
                  int type,
                  int window,
                  datetime time1,
                  double price1,
                  datetime time2=0,
                  double price2=0,
                  datetime time3=0,
                  double price3=0)
bool ObjectCreateMQL4(string name,
                      ENUM_OBJECT type,
                      int window,
                      datetime time1,
                      double price1,
                      datetime time2=0,
                      double price2=0,
                      datetime time3=0,
                      double price3=0)
  {
   return(ObjectCreate(0,name,type,window,
          time1,price1,time2,price2,time3,price3));
  }
ObjectCreate
在指定窗口中创建一个具有指定名称、类型和初始坐标的对象。
ObjectCreate
bool ObjectDelete(string name)
bool ObjectDeleteMQL4(string name)
  {
   return(ObjectDelete(0,name));
  }
ObjectDelete
删除具有指定名称的对象。
ObjectDelete
string ObjectDescription(string name)
string ObjectDescriptionMQL4(string name)
  {
   return(ObjectGetString(0,name,OBJPROP_TEXT));
  }
ObjectDescription
返回对象说明。
ObjectGetString
int ObjectFind(string name)
int ObjectFindMQL4(string name)
  {
   return(ObjectFind(0,name));
  }
ObjectFind
搜索具有指定名称的对象。
ObjectFind
double ObjectGet(string name,
                 int prop_id)
double ObjectGetMQL4(string name,
                     int index)
  {
   switch(index)
     {
      case OBJPROP_TIME1:
         return(ObjectGetInteger(0,name,OBJPROP_TIME));
      case OBJPROP_PRICE1:
         return(ObjectGetDouble(0,name,OBJPROP_PRICE));
      case OBJPROP_TIME2:
         return(ObjectGetInteger(0,name,OBJPROP_TIME,1));
      case OBJPROP_PRICE2:
         return(ObjectGetDouble(0,name,OBJPROP_PRICE,1));
      case OBJPROP_TIME3:
         return(ObjectGetInteger(0,name,OBJPROP_TIME,2));
      case OBJPROP_PRICE3:
         return(ObjectGetDouble(0,name,OBJPROP_PRICE,2));
      case OBJPROP_COLOR:
         return(ObjectGetInteger(0,name,OBJPROP_COLOR));
      case OBJPROP_STYLE:
         return(ObjectGetInteger(0,name,OBJPROP_STYLE));
      case OBJPROP_WIDTH:
         return(ObjectGetInteger(0,name,OBJPROP_WIDTH));
      case OBJPROP_BACK:
         return(ObjectGetInteger(0,name,OBJPROP_WIDTH));
      case OBJPROP_RAY:
         return(ObjectGetInteger(0,name,OBJPROP_RAY_RIGHT));
      case OBJPROP_ELLIPSE:
         return(ObjectGetInteger(0,name,OBJPROP_ELLIPSE));
      case OBJPROP_SCALE:
         return(ObjectGetDouble(0,name,OBJPROP_SCALE));
      case OBJPROP_ANGLE:
         return(ObjectGetDouble(0,name,OBJPROP_ANGLE));
      case OBJPROP_ARROWCODE:
         return(ObjectGetInteger(0,name,OBJPROP_ARROWCODE));
      case OBJPROP_TIMEFRAMES:
         return(ObjectGetInteger(0,name,OBJPROP_TIMEFRAMES));
      case OBJPROP_DEVIATION:
         return(ObjectGetDouble(0,name,OBJPROP_DEVIATION));
      case OBJPROP_FONTSIZE:
         return(ObjectGetInteger(0,name,OBJPROP_FONTSIZE));
      case OBJPROP_CORNER:
         return(ObjectGetInteger(0,name,OBJPROP_CORNER));
      case OBJPROP_XDISTANCE:
         return(ObjectGetInteger(0,name,OBJPROP_XDISTANCE));
      case OBJPROP_YDISTANCE:
         return(ObjectGetInteger(0,name,OBJPROP_YDISTANCE));
      case OBJPROP_FIBOLEVELS:
         return(ObjectGetInteger(0,name,OBJPROP_LEVELS));
      case OBJPROP_LEVELCOLOR:
         return(ObjectGetInteger(0,name,OBJPROP_LEVELCOLOR));
      case OBJPROP_LEVELSTYLE:
         return(ObjectGetInteger(0,name,OBJPROP_LEVELSTYLE));
      case OBJPROP_LEVELWIDTH:
         return(ObjectGetInteger(0,name,OBJPROP_LEVELWIDTH));
     }
  }
ObjectGet
函数返回指定对象属性的值。
ObjectGetIntegerObjectGetDouble

string ObjectGetFiboDescription(string name,
                                int index)
string ObjectGetFiboDescriptionMQL4(string name,
                                    int index)
  {
   return(ObjectGetString(0,name,OBJPROP_LEVELTEXT,index));
  }
ObjectGetFiboDescription
函数返回斐波纳契对象的层级说明。
ObjectGetString
int ObjectGetShiftByValue(string name,
                          double value)
int ObjectGetShiftByValueMQL4(string name,
                              double value)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(PERIOD_CURRENT);
   datetime Arr[];
   int shift;
   MqlRates mql4[];
   if(ObjectGetTimeByValue(0,name,value)<0) return(-1);
   CopyRates(NULL,timeframe,0,1,mql4);
   if(CopyTime(NULL,timeframe,mql4[0].time,
      ObjectGetTimeByValue(0,name,value),Arr)>0)
      return(ArraySize(Arr)-1);
   else return(-1);
  }
ObjectGetShiftByValue
函数计算并返回指定价格的柱索引(相对于当前柱的偏移)。
MqlRatesObjectGetTimeByValueCopyRatesCopyTimeArraySize
double ObjectGetValueByShift(string name,
                             int shift)
double ObjectGetValueByShiftMQL4(string name,
                                 int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(PERIOD_CURRENT);
   MqlRates mql4[];
   CopyRates(NULL,timeframe,shift,1,mql4);
   return(ObjectGetValueByTime(0,name,mql4[0].time,0));
  }
ObjectGetValueByShift
函数计算并返回指定柱(相对于当前柱的偏移)的价格值。
MqlRatesCopyRatesObjectGetValueByTime
bool ObjectMove(string name,
                int point,
                datetime time1,
                double price1)
bool ObjectMoveMQL4(string name,
                    int point,
                    datetime time1,
                    double price1)
  {
   return(ObjectMove(0,name,point,time1,price1));
  }
ObjectMove
函数在图表中移动对象坐标。视它们的类型而定,对象可以有一至三个坐标。
ObjectMove
string ObjectName(int index)
string ObjectNameMQL4(int index)
  {
   return(ObjectName(0,index));
  }
ObjectName
函数按对象在对象列表中的索引返回对象名称。
ObjectName
int ObjectsDeleteAll(int window=EMPTY,
                     int type=EMPTY)
int ObjectsDeleteAllMQL4(int window=EMPTY,
                         int type=EMPTY)
  {
   return(ObjectsDeleteAll(0,window,type));
  }
ObjectsDeleteAll
在指定的图表子窗口中删除指定类型的所有对象。

路过

雷人

握手

鲜花

鸡蛋

QQ|Archiver|小黑屋|www.mtctp.com |

GMT+8, 2024-11-21 18:17 , Processed in 0.031124 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.