找回密码
 立即注册

MQL4>MQL5:自定义指标

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

摘要: 文章来源MQL5官网
 
MQL4
MQL5
 说明
void IndicatorBuffers(int count)
-IndicatorBuffers
为用于自定义指标计算的缓存分配内存。
int IndicatorCounted()
int IndicatorCountedMQL4()
  {
   if(prev_calculated>0) return(prev_calculated-1);
   if(prev_calculated==0) return(0);
   return(0);
  }
IndicatorCounted
函数返回在上一次启动指标之后没有改变的柱的数量。
OnCalculate
void IndicatorDigits(int digits)
bool IndicatorSetInteger(INDICATOR_DIGITS,digits)
IndicatorDigits
设置用于虚拟化指标值的精度格式(小数点后面的位数)。
IndicatorSetInteger
void IndicatorShortName(string name)
bool IndicatorSetString(INDICATOR_SHORTNAME,name)
IndicatorShortName
设置在数据窗口和图表子窗口中显示自定义指标的“短”名称。
IndicatorSetString
void SetIndexArrow(int index,
                   int code)
bool PlotIndexSetInteger(index,PLOT_ARROW,code)
SetIndexArrow
为 DRAW_ARROW 类型的指标线设置一个箭头符号。
PlotIndexSetInteger
bool SetIndexBuffer(int index,
                    double array[])
bool SetIndexBuffer(index,array,INDICATOR_DATA)
SetIndexBuffer
在将全局水平声明的数组变量绑定到自定义指标的预定义缓存。
SetIndexBuffer
void SetIndexDrawBegin(int index,
                       int begin)
bool PlotIndexSetInteger(index,PLOT_DRAW_BEGIN,begin)
SetIndexDrawBegin
设置绘制指定指标线必须从其开始的柱号(从数据开始)。
PlotIndexSetInteger
void SetIndexEmptyValue(int index,
                        double value)
bool PlotIndexSetDouble(index,PLOT_EMPTY_VALUE,value)
SetIndexEmptyValue
将绘制线设置为空值。
PlotIndexSetDouble
void SetIndexLabel(int index,
                   string text)
bool PlotIndexSetString(index,PLOT_LABEL,text)
SetIndexLabel
设置要显示在数据窗口和工具提示中的绘制线说明。
PlotIndexSetString
void SetIndexShift(int index,
                   int shift)
bool PlotIndexSetInteger(index,PLOT_SHIFT,shift)
SetIndexShift
设置绘制线的偏移。
PlotIndexSetInteger
void SetIndexStyle(int index,
                   int type,
                   int style=EMPTY,
                   int width=EMPTY,
                   color clr=CLR_NONE)
void SetIndexStyleMQL4(int index,
                       int type,
                       int style=EMPTY,
                       int width=EMPTY,
                       color clr=CLR_NONE)
  {
   if(width>-1)
      PlotIndexSetInteger(index,PLOT_LINE_WIDTH,width);
   if(clr!=CLR_NONE)
      PlotIndexSetInteger(index,PLOT_LINE_COLOR,clr);
   switch(type)
     {
      case 0:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_LINE);
      case 1:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_SECTION);
      case 2:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_HISTOGRAM);
      case 3:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_ARROW);
      case 4:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_ZIGZAG);
      case 12:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_NONE);

      default:
         PlotIndexSetInteger(index,PLOT_DRAW_TYPE,DRAW_LINE);
     }
   switch(style)
     {
      case 0:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_SOLID);
      case 1:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASH);
      case 2:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DOT);
      case 3:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASHDOT);
      case 4:
         PlotIndexSetInteger(index,PLOT_LINE_STYLE,STYLE_DASHDOTDOT);

      default: return;
     }
SetIndexStyle
为指定的指标线设置新的类型、样式、宽度和颜色。
PlotIndexSetInteger
void SetLevelStyle(int draw_style,
                   int line_width,
                   color clr=CLR_NONE)
void SetLevelStyleMQL4(int draw_style,
                       int line_width,
                       color clr=CLR_NONE)
  {
   IndicatorSetInteger(INDICATOR_LEVELWIDTH,line_width);
   if(clr!=CLR_NONE)
      IndicatorSetInteger(INDICATOR_LEVELCOLOR,clr);
   switch(draw_style)
     {
      case 0:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_SOLID);
      case 1:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASH);
      case 2:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DOT);
      case 3:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASHDOT);
      case 4:
         IndicatorSetInteger(INDICATOR_LEVELSTYLE,STYLE_DASHDOTDOT);

      default: return;
     }
  }
SetLevelStyle
函数设置要在单独的窗口中输出的指标的水平线的新样式、宽度和颜色。
IndicatorSetInteger
void SetLevelValue(int level,
                   double value)
bool IndicatorSetDouble(INDICATOR_LEVELVALUE,level,value)
SetLevelValue
函数设置要在单独的窗口中输出的指标的指定水平线的值。
IndicatorSetDouble

路过

雷人

握手

鲜花

鸡蛋

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

GMT+8, 2024-10-22 16:24 , Processed in 0.033641 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

返回顶部