반응형

캔들 카운터 예시

클릭이후 캔들을 카운트 해주는 인디게이터 입니다.

click_backcount.ex4
0.01MB
click_backcount.mq4
0.00MB

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//+------------------------------------------------------------------+
//|                                                         ck01.mq4 |
//|                                  Copyright 2025, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
 
 
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[])
{
   return(rates_total);
}
#property strict
#property indicator_chart_window
 
int labelCount = 0;
 
int OnInit()
{
    ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true); // 마우스 클릭 이벤트 활성화
    return INIT_SUCCEEDED;
}
 
void DeleteOldLabels()
{
    for (int i = 0; i < labelCount; i++)
    {
        string name = "Label_" + IntegerToString(i);
        ObjectDelete(0, name);
    }
    labelCount = 0;
}
 
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
    if (id == CHARTEVENT_CLICK)
    {
        // 클릭 위치 → 시간 변환
        int x = (int)lparam;
        datetime clickTime;
        double price;
        int window=0;
        if (!ChartXYToTimePrice(0, x, 0,window, clickTime, price))
            return;
 
        // 시간 → 봉 인덱스
        int clickIndex = iBarShift(NULL0, clickTime, false);
        int totalBars = iBars(NULL0);
        if (clickIndex >= totalBars - 1return;
 
        DeleteOldLabels(); // 이전 숫자 라벨 삭제
 
        // 클릭 이후 봉들에 숫자 순차 표시
        int count = 1;
        for (int i = clickIndex + 1; i < totalBars; i++)
        {
            string labelName = "Label_" + IntegerToString(labelCount);
            datetime barTime = iTime(NULL0, i);
            double barHigh = iHigh(NULL0, i);
 
            ObjectCreate(0, labelName, OBJ_TEXT, 0, barTime, barHigh + (Point * 10));
            ObjectSetText(labelName, IntegerToString(count), 15"Arial", clrWhite);
            ObjectSetInteger(0, labelName, OBJPROP_BACK, false);
 
            count++;
            labelCount++;
        }
 
        ChartRedraw();
    }
}
cs

" target="_blank" rel="noopener" data-mce-href="http://

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//+------------------------------------------------------------------+
//|                                                         ck01.mq4 |
//|                                  Copyright 2025, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
 
 
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[])
{
   return(rates_total);
}
#property strict
#property indicator_chart_window
 
int labelCount = 0;
 
int OnInit()
{
    ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true); // 마우스 클릭 이벤트 활성화
    return INIT_SUCCEEDED;
}
 
void DeleteOldLabels()
{
    for (int i = 0; i < labelCount; i++)
    {
        string name = "Label_" + IntegerToString(i);
        ObjectDelete(0, name);
    }
    labelCount = 0;
}
 
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
    if (id == CHARTEVENT_CLICK)
    {
        // 클릭 위치 → 시간 변환
        int x = (int)lparam;
        datetime clickTime;
        double price;
        int window=0;
        if (!ChartXYToTimePrice(0, x, 0,window, clickTime, price))
            return;
 
        // 시간 → 봉 인덱스
        int clickIndex = iBarShift(NULL0, clickTime, false);
        int totalBars = iBars(NULL0);
        if (clickIndex >= totalBars - 1return;
 
        DeleteOldLabels(); // 이전 숫자 라벨 삭제
 
        // 클릭 이후 봉들에 숫자 순차 표시
        int count = 1;
        for (int i = clickIndex + 1; i < totalBars; i++)
        {
            string labelName = "Label_" + IntegerToString(labelCount);
            datetime barTime = iTime(NULL0, i);
            double barHigh = iHigh(NULL0, i);
 
            ObjectCreate(0, labelName, OBJ_TEXT, 0, barTime, barHigh + (Point * 10));
            ObjectSetText(labelName, IntegerToString(count), 15"Arial", clrWhite);
            ObjectSetInteger(0, labelName, OBJPROP_BACK, false);
 
            count++;
            labelCount++;
        }
 
        ChartRedraw();
    }
}
cs

">http://

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//+------------------------------------------------------------------+
//|                                                         ck01.mq4 |
//|                                  Copyright 2025, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
 
 
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[])
{
   return(rates_total);
}
#property strict
#property indicator_chart_window
 
int labelCount = 0;
 
int OnInit()
{
    ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true); // 마우스 클릭 이벤트 활성화
    return INIT_SUCCEEDED;
}
 
void DeleteOldLabels()
{
    for (int i = 0; i < labelCount; i++)
    {
        string name = "Label_" + IntegerToString(i);
        ObjectDelete(0, name);
    }
    labelCount = 0;
}
 
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
    if (id == CHARTEVENT_CLICK)
    {
        // 클릭 위치 → 시간 변환
        int x = (int)lparam;
        datetime clickTime;
        double price;
        int window=0;
        if (!ChartXYToTimePrice(0, x, 0,window, clickTime, price))
            return;
 
        // 시간 → 봉 인덱스
        int clickIndex = iBarShift(NULL0, clickTime, false);
        int totalBars = iBars(NULL0);
        if (clickIndex >= totalBars - 1return;
 
        DeleteOldLabels(); // 이전 숫자 라벨 삭제
 
        // 클릭 이후 봉들에 숫자 순차 표시
        int count = 1;
        for (int i = clickIndex + 1; i < totalBars; i++)
        {
            string labelName = "Label_" + IntegerToString(labelCount);
            datetime barTime = iTime(NULL0, i);
            double barHigh = iHigh(NULL0, i);
 
            ObjectCreate(0, labelName, OBJ_TEXT, 0, barTime, barHigh + (Point * 10));
            ObjectSetText(labelName, IntegerToString(count), 15"Arial", clrWhite);
            ObjectSetInteger(0, labelName, OBJPROP_BACK, false);
 
            count++;
            labelCount++;
        }
 
        ChartRedraw();
    }
}
cs

 

반응형

'외환 forex mt4' 카테고리의 다른 글

비트코인 시황  (0) 2025.05.25
급등 패턴 외환 정리  (0) 2025.05.25
일목균형표 보조 인디게이터  (0) 2025.05.24
MTF 다중시간대 분석  (0) 2025.05.24
금값 차트보고 매매  (0) 2025.05.24

+ Recent posts