#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
//---- 플롯 수
#property indicator_label1 "숫자"
#property indicator_type1 DRAW_LINE
#property indicator_color1 CLR_NONE
//--- 지표 버퍼
double NumerationBuffer[];
//+------------------------------------------------------------------+
//| 사용자 지정 지표 초기화 함수 |
//+------------------------------------------------------------------+
int OnInit()
{
//--- 지표 버퍼 맵핑
SetIndexBuffer(0,NumerationBuffer,INDICATOR_DATA);
//--- 시계열에서처럼 버퍼에 대한 인덱싱 설정
ArraySetAsSeries(NumerationBuffer,true);
//--- DataWindow에 표시되는 정확도 설정
IndicatorSetInteger(INDICATOR_DIGITS,0);
//--- 지표 배열 이름이 DataWindow에 표시되는 방법
PlotIndexSetString(0,PLOT_LABEL,"Bar #");
//---
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[])
{
//--- 현재 0 막대의 개장 시간을 저장하겠습니다
static datetime currentBarTimeOpen=0;
//--- time[] 배열로 액세스 되돌리기 - 시계열처럼 실행
ArraySetAsSeries(time,true);
//--- 0 막대의 시간이 저장된 시간과 다를 경우
if(currentBarTimeOpen!=time[0])
{
//--- 현재에서 차트 깊이까지 모든 막대를 열거
for(int i=rates_total-1;i>=0;i--) NumerationBuffer[i]=i;
currentBarTimeOpen=time[0];
}
//--- 다음 호출을 위한 prev_calculated의 반환 값
return(rates_total);
}
|