PlotIndexGetInteger

该函数建立一定特征的相应值,指标性质应该是整型,颜色型,布尔型或者字符型。有两种变量函数。

调用指定属性标识符。

int  PlotIndexGetInteger(
   int  plot_index,        // 图样式指数
   int  prop_id,           // 属性标识符
   );

调用指定属性标识符和修饰符。

int  PlotIndexGetInteger(
   int  plot_index,        // 绘图指数
   int  prop_id,           // 属性标识符
   int  prop_modifier      // 属性修饰符
   )

参量

plot_index

[in]   图解 索引

prop_id

[in] 该值可以是 ENUM_PLOT_PROPERTY_INTEGER 列举值中的一个。

prop_modifier

[in]  规定属性的修饰符,只有显色指数性能要求修改。

注释

函数用来提取适当指示线路的绘画设置,该函数与PlotIndexSetInteger函数串联,通过复制绘图性质从一条线绘制到另一条线里。

示例:指标的色彩平台以周为单位。每天的颜色都在程序中体现。

Candlsticks colored in accordance with the weekday number

 

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_plots   1
//---- 蜡烛颜色图
#property indicator_label1  "ColorCandles"
#property indicator_type1   DRAW_COLOR_CANDLES
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- 指标缓冲区
double         OpenBuffer[];
double         HighBuffer[];
double         LowBuffer[];
double         CloseBuffer[];
double         ColorCandlesColors[];
color          ColorOfDay[6]={CLR_NONE,clrMediumSlateBlue,
                              clrDarkGoldenrod,clrForestGreen,clrBlueViolet,clrRed};
//+------------------------------------------------------------------+
//| 自定义指标初始化函数                                                |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- 指标缓冲区绘图
   SetIndexBuffer(0,OpenBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,HighBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,LowBuffer,INDICATOR_DATA);
   SetIndexBuffer(3,CloseBuffer,INDICATOR_DATA);
   SetIndexBuffer(4,ColorCandlesColors,INDICATOR_COLOR_INDEX);
//--- 颜色缓存区设置颜色数
   PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,6);
//--- 为颜色缓存设置颜色
   for(int i=1;i<6;i++)
      PlotIndexSetInteger(0,PLOT_LINE_COLOR,i,ColorOfDay[i]);
//--- 设置精确度
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
   printf("We have %u colors of days",PlotIndexGetInteger(0,PLOT_COLOR_INDEXES));
//---
  }
//+------------------------------------------------------------------+
//| 自定义指标重复函数                                                 |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i;
   MqlDateTime t;
//----
   if(prev_calculated==0) i=0;
   else i=prev_calculated-1;
//----
   while(i<rates_total)
     {
      OpenBuffer[i]=open[i];
      HighBuffer[i]=high[i];
      LowBuffer[i]=low[i];
      CloseBuffer[i]=close[i];
      //--- 为每个蜡烛设置颜色
      TimeToStruct(time[i],t);
      ColorCandlesColors[i]=t.day_of_week;
      //---
      i++;
     }
//--- 为下一次调用返回prev_calculated值
   return(rates_total);
  }
//+------------------------------------------------------------------+