DRAW_NONE

DRAW_NONE 스타일은 버퍼의 값을 계산하여 데이터 창에 표시해야 하는 경우에 사용하도록 설계되었지만 차트의 플롯은 필요하지 않습니다. 정확도를 설정하려면 OnInit() 함수에서 IndicatorSetInteger(INDICATOR_DIGITS,num_chars를 사용합니다:

int OnInit()
  {
//--- 지표 버퍼 맵핑
   SetIndexBuffer(0,InvisibleBuffer,INDICATOR_DATA);
//--- 데이터 창에 표시할 값의 정확도 설정
   IndicatorSetInteger(INDICATOR_DIGITS,0);
//---
   return(INIT_SUCCEEDED);
  }

DRAW_NONE을 플로팅하는 데 필요한 버퍼 수는 1개입니다.

데이터 창에서 마우스가 현재 가리키는 막대의 수를 보여주는 지표의 예. 번호 지정은 시계열과 일치하며, 즉, 현재 완료되지 않은 막대의 인덱스가 0이고 가장 오래된 막대의 인덱스가 가장 큽니다.

DRAW_NONE의 예

빨간색은 플로팅 #1로 설정되어 있지만 지표는 차트에 아무 것도 그리지 않습니다.

//+------------------------------------------------------------------+
//|                                                    DRAW_NONE.mq5 |
//|                         Copyright 2000-2024, MetaQuotes Ltd. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2000-2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- Invisible 플롯
#property indicator_label1  "막대 인덱스"
#property indicator_type1   DRAW_NONE
#property indicator_style1  STYLE_SOLID
#property indicator_color1  clrRed
#property indicator_width1  1
//--- 지표 버퍼
double         InvisibleBuffer[];
//+------------------------------------------------------------------+
//| 사용자 지정 지표 초기화 함수                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 지표 버퍼 및 배열 바인딩
   SetIndexBuffer(0,InvisibleBuffer,INDICATOR_DATA);
//--- 데이터 창에 표시할 값의 정확도 설정
   IndicatorSetInteger(INDICATOR_DIGITS,0);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 사용자 지정 지표 반복 함수                              |
//+------------------------------------------------------------------+
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[])
  {
   static datetime lastbar=0;
//--- 지표의 첫 번째 계산인 경우
   if(prev_calculated==0)
     {
      //--- 막대 번호를 처음으로 다시 매깁니다
      CalcValues(rates_total,close);
      //--- 마지막 막대에서 현재 막대의 개방 시간을 기억
      lastbar=(datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
     }
   else
     {
      //--- 새 막대가 나타난 경우 막대와 개방 시간이 다릅니다
      if(lastbar!=SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE))
        {
         //--- 막대 번호를 다시 한 번 변경
         CalcValues(rates_total,close);
         //--- 마지막 막대에 있는 현재 막대의 개방 시간 업데이트
         lastbar=(datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
        }
     }
//--- 다음 호출을 위한 prev_calculated의 반환 값
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| 시계열처럼 막대에 번호를 매김                             |
//+------------------------------------------------------------------+
void CalcValues(int total,double const  &array[])
  {
//--- 지표 버퍼의 인떽싱을 시계열처럼 설정
   ArraySetAsSeries(InvisibleBuffer,true);
//--- 각 막대에 해당 번호를 입력
   for(int i=0;i<total;i++) InvisibleBuffer[i]=i;
  }