須計算「+DM」、「-DM」、「真實+DM」、「真實-DM」、「+DM(14)」、「–DM(14)」
1.把當日最高價減去前一日最高價 = +DM。
2.前一日最低價減去當日最低價 = -DM。
3.若+DM>-DM成立,且+DM大於0,則「真實+DM」= +DM,若+DM小於等於0,則「真實+DM」= 0。
4.同理,若+DM<-DM且-DM大於0,則「真實-DM」= -DM,若-DM小於等於0,則「真實-DM」= 0。
5.接下來計算 +DM(14)與 –DM(14)之值。
起始值:可先用前14天之「真實+DM」的平均數做為第一天之+DM(14),用前14天之「真實-DM」的平均數做為第一天之-DM(14),而後計算如下:
當日+DM(14)=前一日+DM(14)*(13/14) + 當日真實+DM*(1/14)
當日-DM(14)=前一日 -DM14*(13/14) + 當日真實 -DM*(1/14)
再算出TR值 (當日價格與前一日價格相比之最大波動值)
TR(True Range)為波動實值,其算法為取以下三值中的最大一值,如下:
1、為當日最高價減去當日最低價。
2、∣Ht-C(t-1)∣ 為當日最高價減去前一日收盤價的絕對值。
3、∣C(t-1)-Lt∣為前一日收盤價減去當日最低價絕對值。
公式TR=MAX(Ht-Lt,∣Ht-C(t-1)∣,∣C(t-1)-Lt∣)
可簡化為 TR=MAX(H,L,前日收)-MIN(H,L,前日收)
再計算 TR(14):起始值計算比照DM(14)之計算方式,取前14根做平均數。
當日TR(14)=前一日TR14*(13/14) + 今日TR*(1/14)
以上為合併DM值與TR值之呈現:
然後算出DI值
+DI(14)=+DM(14)/ TR(14) * 100
-DI(14)=-DM(14)/ TR(14) * 100
如果+DI(14)為36,代表上攻力道中有36﹪的價格變動是真實有效的,如果-DI(14)為20,代表下殺力道中有20價格變動是真實有效跌破的。而真實有效的值才可列入ADX的計算。
例:以下列五個圖形來論,不論圖形之1、3、4之TR值都是相同的,因為前一根K棒收盤被這一根K棒高低點包住,所以若+DM相同,其對+DI的貢獻度是一樣的;較不同的應是1與2的比較,一般來說圖形2是從空頭直接拉上來的,感覺好像是比較強,可是在+DI的解釋反而是較小的(因為分子+DM一樣、但圖2之TR值比圖1大,分母大、值就小),代表圖2之後較易盤整,也就是急速轉折後勢易盤;而下列對DI貢獻最大的為圖5,表示開高走高在多頭的意義也是最大的,也就是創新高的能力會直接反應在此指標上。
最後算出DX及ADX
ADX(趨向平均線)是用來判別14日內價格變動趨勢的明顯度,計算如下:
1、先取DX值:DX=∣(+DI 14)- (-DI14)∣/ ((+DI14)+ (-DI14))。
再取ADX值:起始值計算比照DM(14)之計算方式,取前14根做平均數。
當日ADX(14)=前一日ADX*(13/14) + 今日DX*(1/14)
2、ADX向上,表示價格變動的趨勢力量愈大,亦愈有可能產生連續行情,反之若向下,通常伴隨著是橫向整理。
ADX愈大、代表目前市場上潛藏的動能愈強,任何方向皆可能有波段產生。
以下為一真實的歷史資料庫試算,給有興趣的投資人參考:
日期
|
最高
|
最低
|
收盤
|
+DM
|
-DM
|
真+DM
|
真-DM
|
真+DM14
|
真-DM14
|
TR
|
TR14
|
+DI
|
-DI
|
DX
|
ADX14
|
2006/10/18
|
7057
|
6976
|
7025
|
2006/10/19
|
7033
|
6961
|
6981
|
-24
|
15
|
0
|
15
|
72
|
2006/10/20
|
7026
|
6997
|
7017
|
-7
|
-36
|
0
|
0
|
45
|
2006/10/23
|
7050
|
6977
|
7049
|
24
|
20
|
24
|
0
|
73
|
2006/10/24
|
7120
|
7058
|
7097
|
70
|
-81
|
70
|
0
|
71
|
2006/10/25
|
7105
|
7060
|
7060
|
-15
|
-2
|
0
|
0
|
45
|
2006/10/26
|
7125
|
7072
|
7093
|
20
|
-12
|
20
|
0
|
65
|
2006/10/27
|
7130
|
7077
|
7093
|
5
|
-5
|
5
|
0
|
53
|
2006/10/30
|
7035
|
6976
|
6981
|
-95
|
101
|
0
|
101
|
117
|
2006/10/31
|
7009
|
6966
|
7002
|
-26
|
10
|
0
|
10
|
43
|
2006/11/1
|
7025
|
6992
|
7003
|
16
|
-26
|
16
|
0
|
33
|
2006/11/2
|
7072
|
6956
|
7063
|
47
|
36
|
47
|
0
|
116
|
2006/11/3
|
7179
|
7055
|
7141
|
107
|
-99
|
107
|
0
|
124
|
2006/11/6
|
7156
|
7045
|
7115
|
-23
|
10
|
0
|
10
|
111
|
2006/11/7
|
7211
|
7163
|
7183
|
55
|
-118
|
55
|
0
|
24.571
|
9.714
|
96
|
76.000
|
32.33
|
12.78
|
43.333
|
2006/11/8
|
7190
|
7154
|
7156
|
-21
|
9
|
0
|
9
|
22.816
|
9.663
|
36
|
73.143
|
31.19
|
13.21
|
40.496
|
2006/11/9
|
7232
|
7110
|
7128
|
42
|
44
|
0
|
44
|
21.187
|
12.116
|
122
|
76.633
|
27.65
|
15.81
|
27.237
|
2006/11/10
|
7164
|
7102
|
7162
|
-68
|
8
|
0
|
8
|
19.673
|
11.822
|
62
|
75.587
|
26.03
|
15.64
|
24.929
|
2006/11/13
|
7178
|
7110
|
7132
|
14
|
-8
|
14
|
0
|
19.268
|
10.977
|
68
|
75.046
|
25.68
|
14.63
|
27.411
|
2006/11/14
|
7212
|
7162
|
7206
|
34
|
-52
|
34
|
0
|
20.320
|
10.193
|
80
|
75.399
|
26.95
|
13.52
|
33.188
|
2006/11/15
|
7266
|
7216
|
7247
|
54
|
-54
|
54
|
0
|
22.726
|
9.465
|
60
|
74.299
|
30.59
|
12.74
|
41.194
|
2006/11/16
|
7270
|
7231
|
7248
|
4
|
-15
|
4
|
0
|
21.388
|
8.789
|
39
|
71.778
|
29.80
|
12.24
|
41.750
|
2006/11/17
|
7274
|
7238
|
7257
|
4
|
-7
|
4
|
0
|
20.146
|
8.161
|
36
|
69.222
|
29.10
|
11.79
|
42.338
|
2006/11/20
|
7248
|
7205
|
7220
|
-26
|
33
|
0
|
33
|
18.707
|
9.936
|
52
|
67.992
|
27.51
|
14.61
|
30.625
|
2006/11/21
|
7311
|
7226
|
7306
|
63
|
-21
|
63
|
0
|
21.871
|
9.226
|
91
|
69.636
|
31.41
|
13.25
|
40.664
|
2006/11/22
|
7345
|
7297
|
7343
|
34
|
-71
|
34
|
0
|
22.737
|
8.567
|
48
|
68.090
|
33.39
|
12.58
|
45.267
|
2006/11/23
|
7427
|
7337
|
7394
|
82
|
-40
|
82
|
0
|
26.971
|
7.955
|
90
|
69.655
|
38.72
|
11.42
|
54.446
|
2006/11/24
|
7437
|
7363
|
7433
|
10
|
-26
|
10
|
0
|
25.758
|
7.387
|
74
|
69.966
|
36.82
|
10.56
|
55.428
|
39.16
|
2006/11/27
|
7515
|
7451
|
7510
|
78
|
-88
|
78
|
0
|
29.490
|
6.859
|
82
|
70.825
|
41.64
|
9.68
|
62.260
|
40.81
|
2006/11/28
|
7475
|
7435
|
7454
|
-40
|
16
|
0
|
16
|
27.383
|
7.512
|
75
|
71.123
|
38.50
|
10.56
|
56.945
|
41.97
|
2006/11/29
|
7498
|
7395
|
7465
|
23
|
40
|
0
|
40
|
25.428
|
9.833
|
103
|
73.400
|
34.64
|
13.40
|
44.228
|
42.13
|
2006/11/30
|
7553
|
7475
|
7542
|
55
|
-80
|
55
|
0
|
27.540
|
9.130
|
88
|
74.443
|
36.99
|
12.26
|
50.203
|
42.70
|
2006/12/1
|
7626
|
7537
|
7612
|
73
|
-62
|
73
|
0
|
30.787
|
8.478
|
89
|
75.483
|
40.79
|
11.23
|
56.816
|
43.71
|
2006/12/4
|
7674
|
7585
|
7658
|
48
|
-48
|
48
|
0
|
32.016
|
7.873
|
89
|
76.448
|
41.88
|
10.30
|
60.528
|
44.91
|
2006/12/5
|
7704
|
7565
|
7610
|
30
|
20
|
30
|
0
|
31.872
|
7.310
|
139
|
80.916
|
39.39
|
9.03
|
62.686
|
46.18
|
2006/12/6
|
7714
|
7610
|
7714
|
10
|
-45
|
10
|
0
|
30.310
|
6.788
|
104
|
82.565
|
36.71
|
8.22
|
63.405
|
47.41
|
2006/12/7
|
7738
|
7672
|
7698
|
24
|
-62
|
24
|
0
|
29.859
|
6.303
|
66
|
81.382
|
36.69
|
7.75
|
65.140
|
48.68
|
2006/12/8
|
7679
|
7598
|
7633
|
-59
|
74
|
0
|
74
|
27.727
|
11.139
|
100
|
82.712
|
33.52
|
13.47
|
42.681
|
48.25
|
2006/12/11
|
7639
|
7575
|
7614
|
-40
|
23
|
0
|
23
|
25.746
|
11.986
|
64
|
81.375
|
31.64
|
14.73
|
36.468
|
47.41
|
2006/12/12
|
7608
|
7454
|
7467
|
-31
|
121
|
0
|
121
|
23.907
|
19.773
|
160
|
86.991
|
27.48
|
22.73
|
9.465
|
44.70
|
2006/12/13
|
7500
|
7375
|
7450
|
-108
|
79
|
0
|
79
|
22.199
|
24.003
|
125
|
89.706
|
24.75
|
26.76
|
3.904
|
41.79
|
2006/12/14
|
7491
|
7427
|
7478
|
-9
|
-52
|
0
|
0
|
20.614
|
22.289
|
64
|
87.870
|
23.46
|
25.37
|
3.904
|
39.08
|
2006/12/15
|
7568
|
7525
|
7540
|
77
|
-98
|
77
|
0
|
24.641
|
20.697
|
90
|
88.022
|
27.99
|
23.51
|
8.701
|
36.91
|
2006/12/18
|
7668
|
7540
|
7634
|
100
|
-15
|
100
|
0
|
30.024
|
19.218
|
128
|
90.878
|
33.04
|
21.15
|
21.944
|
35.84
|
2006/12/19
|
7675
|
7583
|
7593
|
7
|
-43
|
7
|
0
|
28.380
|
17.846
|
92
|
90.958
|
31.20
|
19.62
|
22.788
|
34.91
|
2006/12/20
|
7678
|
7602
|
7662
|
3
|
-19
|
3
|
0
|
26.567
|
16.571
|
85
|
90.532
|
29.35
|
18.30
|
23.172
|
34.07
|
2006/12/21
|
7710
|
7617
|
7642
|
32
|
-15
|
32
|
0
|
26.955
|
15.387
|
93
|
90.709
|
29.72
|
16.96
|
27.319
|
33.59
|
2006/12/22
|
7692
|
7625
|
7692
|
-18
|
-8
|
0
|
0
|
25.029
|
14.288
|
67
|
89.015
|
28.12
|
16.05
|
27.319
|
33.14
|
2006/12/25
|
7698
|
7656
|
7679
|
6
|
-31
|
6
|
0
|
23.670
|
13.268
|
42
|
85.657
|
27.63
|
15.49
|
28.163
|
32.78
|
2006/12/26
|
7802
|
7674
|
7789
|
104
|
-18
|
104
|
0
|
29.408
|
12.320
|
128
|
88.681
|
33.16
|
13.89
|
40.951
|
33.37
|
2006/12/27
|
7845
|
7778
|
7795
|
43
|
-104
|
43
|
0
|
30.379
|
11.440
|
67
|
87.133
|
34.87
|
13.13
|
45.288
|
34.22
|
2006/12/28
|
7840
|
7746
|
7800
|
-5
|
32
|
0
|
32
|
28.209
|
12.908
|
94
|
87.623
|
32.19
|
14.73
|
37.212
|
34.43
|
2006/12/29
|
7888
|
7793
|
7880
|
48
|
-47
|
48
|
0
|
29.623
|
11.986
|
95
|
88.150
|
33.60
|
13.60
|
42.385
|
35.00
|
2007/1/2
|
7992
|
7880
|
7988
|
104
|
-87
|
104
|
0
|
34.935
|
11.130
|
112
|
89.854
|
38.88
|
12.39
|
51.676
|
36.19
|
2007/1/3
|
8035
|
7953
|
7989
|
43
|
-73
|
43
|
0
|
35.511
|
10.335
|
82
|
89.293
|
39.77
|
11.57
|
54.914
|
37.53
|
2007/1/4
|
7996
|
7936
|
7976
|
-39
|
17
|
0
|
17
|
32.975
|
10.811
|
60
|
87.200
|
37.81
|
12.40
|
50.618
|
38.46
|
2007/1/5
|
7989
|
7828
|
7830
|
-7
|
108
|
0
|
108
|
30.619
|
17.753
|
161
|
92.472
|
33.11
|
19.20
|
26.598
|
37.62
|
2007/1/8
|
7808
|
7726
|
7736
|
-181
|
102
|
0
|
102
|
28.432
|
23.771
|
104
|
93.295
|
30.48
|
25.48
|
8.929
|
35.57
|
2007/1/9
|
7835
|
7750
|
7822
|
27
|
-24
|
27
|
0
|
28.330
|
22.073
|
99
|
93.703
|
30.23
|
23.56
|
12.414
|
33.91
|
2007/1/10
|
7761
|
7670
|
7693
|
-74
|
80
|
0
|
80
|
26.306
|
26.211
|
152
|
97.867
|
26.88
|
26.78
|
0.182
|
31.50
|
2007/1/11
|
7738
|
7594
|
7626
|
-23
|
76
|
0
|
76
|
24.427
|
29.767
|
144
|
101.162
|
24.15
|
29.43
|
9.853
|
29.96
|
2007/1/12
|
7795
|
7687
|
7786
|
57
|
-93
|
57
|
0
|
26.754
|
27.641
|
169
|
106.008
|
25.24
|
26.07
|
1.630
|
27.93
|
2007/1/15
|
7833
|
7746
|
7804
|
38
|
-59
|
38
|
0
|
27.557
|
25.666
|
87
|
104.650
|
26.33
|
24.53
|
3.553
|
26.19
|
2007/1/16
|
7847
|
7785
|
7815
|
14
|
-39
|
14
|
0
|
26.589
|
23.833
|
62
|
101.604
|
26.17
|
23.46
|
5.465
|
24.71
|
2007/1/17
|
7856
|
7711
|
7835
|
9
|
74
|
0
|
74
|
24.690
|
27.417
|
145
|
104.703
|
23.58
|
26.18
|
5.233
|
23.32
|
2007/1/18
|
7930
|
7840
|
7922
|
74
|
-129
|
74
|
0
|
28.212
|
25.458
|
95
|
104.010
|
27.12
|
24.48
|
5.131
|
22.02
|
2007/1/19
|
7921
|
7856
|
7862
|
-9
|
-16
|
0
|
0
|
26.197
|
23.640
|
66
|
101.295
|
25.86
|
23.34
|
5.131
|
20.82
|
2007/1/22
|
7903
|
7780
|
7885
|
-18
|
76
|
0
|
76
|
24.326
|
27.380
|
123
|
102.846
|
23.65
|
26.62
|
5.907
|
19.75
|
2007/1/23
|
7892
|
7826
|
7885
|
-11
|
-46
|
0
|
0
|
22.588
|
25.424
|
66
|
100.214
|
22.54
|
25.37
|
5.907
|
18.76
|
2007/1/24
|
7996
|
7954
|
7993
|
104
|
-128
|
104
|
0
|
28.403
|
23.608
|
111
|
100.984
|
28.13
|
23.38
|
9.219
|
18.08
|
2007/1/25
|
8033
|
7960
|
7975
|
37
|
-6
|
37
|
0
|
29.017
|
21.922
|
73
|
98.985
|
29.31
|
22.15
|
13.929
|
17.78
|
2007/1/26
|
7915
|
7811
|
7837
|
-118
|
149
|
0
|
149
|
26.945
|
30.999
|
164
|
103.629
|
26.00
|
29.91
|
6.997
|
17.01
|
2007/1/29
|
7857
|
7756
|
7787
|
-58
|
55
|
0
|
55
|
25.020
|
32.713
|
101
|
103.441
|
24.19
|
31.62
|
13.325
|
16.75
|
2007/1/30
|
7807
|
7752
|
7769
|
-50
|
4
|
0
|
4
|
23.233
|
30.662
|
55
|
99.981
|
23.24
|
30.67
|
13.785
|
16.54
|
2007/1/31
|
7793
|
7638
|
7734
|
-14
|
114
|
0
|
114
|
21.573
|
36.615
|
155
|
103.911
|
20.76
|
35.24
|
25.850
|
17.20
|
2007/2/1
|
7786
|
7692
|
7740
|
-7
|
-54
|
0
|
0
|
20.032
|
34.000
|
94
|
103.203
|
19.41
|
32.94
|
25.850
|
17.82
|
2007/2/2
|
7839
|
7781
|
7810
|
53
|
-89
|
53
|
0
|
22.387
|
31.571
|
99
|
102.903
|
21.76
|
30.68
|
17.020
|
17.76
|
2007/2/5
|
7836
|
7760
|
7779
|
-3
|
21
|
0
|
21
|
20.788
|
30.816
|
76
|
100.981
|
20.59
|
30.52
|
19.432
|
17.88
|
2007/2/6
|
7896
|
7791
|
7889
|
60
|
-31
|
60
|
0
|
23.589
|
28.615
|
117
|
102.126
|
23.10
|
28.02
|
9.627
|
17.29
|
2007/2/7
|
7899
|
7860
|
7868
|
3
|
-69
|
3
|
0
|
22.118
|
26.571
|
39
|
97.617
|
22.66
|
27.22
|
9.145
|
16.71
|
2007/2/8
|
7907
|
7803
|
7870
|
8
|
57
|
0
|
57
|
20.538
|
28.744
|
104
|
98.073
|
20.94
|
29.31
|
16.651
|
16.71
|
2007/2/9
|
7925
|
7845
|
7884
|
18
|
-42
|
18
|
0
|
20.357
|
26.691
|
80
|
96.782
|
21.03
|
27.58
|
13.463
|
16.47
|
2007/2/12
|
7844
|
7784
|
7792
|
-81
|
61
|
0
|
61
|
18.903
|
29.142
|
100
|
97.012
|
19.49
|
30.04
|
21.311
|
16.82
|
2007/2/13
|
7830
|
7742
|
7743
|
-14
|
42
|
0
|
42
|
17.553
|
30.060
|
88
|
96.368
|
18.21
|
31.19
|
26.269
|
17.50
|
2007/2/14
|
7841
|
7776
|
7833
|
11
|
-34
|
11
|
0
|
17.085
|
27.913
|
98
|
96.484
|
17.71
|
28.93
|
24.064
|
17.96
|
2007/2/26
|
7945
|
7899
|
7899
|
104
|
-123
|
104
|
0
|
23.293
|
25.919
|
112
|
97.593
|
23.87
|
26.56
|
5.337
|
17.06
|
2007/2/27
|
7970
|
7911
|
7925
|
25
|
-12
|
25
|
0
|
23.415
|
24.068
|
71
|
95.693
|
24.47
|
25.15
|
1.375
|
15.94
|
2007/3/1
|
7771
|
7652
|
7660
|
-199
|
259
|
0
|
259
|
21.742
|
40.849
|
273
|
108.358
|
20.07
|
37.70
|
30.526
|
16.98
|
2007/3/2
|
7694
|
7611
|
7668
|
-77
|
41
|
0
|
41
|
20.189
|
40.860
|
83
|
106.547
|
18.95
|
38.35
|
33.858
|
18.19
|
2007/3/3
|
7640
|
7556
|
7589
|
-54
|
55
|
0
|
55
|
18.747
|
41.870
|
112
|
106.936
|
17.53
|
39.15
|
38.145
|
19.61
|
2007/3/5
|
7548
|
7270
|
7285
|
-92
|
286
|
0
|
286
|
17.408
|
59.308
|
319
|
122.084
|
14.26
|
48.58
|
54.616
|
22.11
|
2007/3/6
|
7425
|
7320
|
7409
|
-123
|
-50
|
0
|
0
|
16.165
|
55.071
|
140
|
123.363
|
13.10
|
44.64
|
54.616
|
24.44
|
2007/3/7
|
7469
|
7383
|
7427
|
44
|
-63
|
44
|
0
|
18.153
|
51.138
|
86
|
120.695
|
15.04
|
42.37
|
47.603
|
26.09
|
2007/3/8
|
7534
|
7417
|
7523
|
65
|
-34
|
65
|
0
|
21.499
|
47.485
|
117
|
120.431
|
17.85
|
39.43
|
37.669
|
26.92
|
2007/3/9
|
7566
|
7492
|
7517
|
32
|
-75
|
32
|
0
|
22.249
|
44.093
|
74
|
117.114
|
19.00
|
37.65
|
32.926
|
27.35
|
2007/3/12
|
7595
|
7541
|
7595
|
29
|
-49
|
29
|
0
|
22.731
|
40.944
|
78
|
114.320
|
19.88
|
35.81
|
28.602
|
27.44
|
2007/3/13
|
7643
|
7581
|
7624
|
48
|
-40
|
48
|
0
|
24.536
|
38.019
|
62
|
110.583
|
22.19
|
34.38
|
21.553
|
27.02
|
2007/3/14
|
7518
|
7435
|
7469
|
-125
|
146
|
0
|
146
|
22.784
|
45.732
|
189
|
116.184
|
19.61
|
39.36
|
33.493
|
27.48
|
2007/3/15
|
7677
|
7530
|
7652
|
159
|
-95
|
159
|
0
|
32.513
|
42.465
|
208
|
122.743
|
26.49
|
34.60
|
13.273
|
26.46
|
2007/3/16
|
7724
|
7580
|
7666
|
47
|
-50
|
47
|
0
|
33.548
|
39.432
|
144
|
124.261
|
27.00
|
31.73
|
8.062
|
25.15
|