PlotIndexGetInteger

기능은 해당 지표 선의 해당 속성 값을 설정합니다. 지표 속성은 int, color, bool 또는 char 유형이어야 합니다. 이 기능의 변수는 2 가지가 있습니다.

속성의 식별자를 나타내는 호출.

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 기능과 함께 작동하여 한 라인의 그리기 속성을 다른 선으로 복사합니다.

예: 요일에 따라 캔들스틱을 채색하는 지표. 각 일별 색상은 프로그래밍 방식으로 설정됩니다.

평일 숫자에 따라 채색된 캔들스틱

 

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_plots   1
//---- ColorCandles 플롯
#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("요일 %u 색상이 있습니다",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);
  }
//+------------------------------------------------------------------+