【學習筆記】指數平滑異同移動平均線 Moving Average Convergence / Divergence
指數平滑異同移動平均線(Moving Average Convergence / Divergence, MACD)
計算方式
1 | MACD = EMA(DIF, 9) |
舉例陽明(2609) 111/02/18 的 MACD
- 計算 EMA(12)
加權指數
K = 平滑因子 / (時間週期 + 1)
= Something / (N + 1)
= 2 / (12 + 1)
= 2 / 13
= 0.1538461538461538
EMA(12) = (今日收盤價 * 加權指數) + 昨日 EMA * (1 - 加權指數)
= (Today CP * K) + Yesterday EMA * (1 - K)
= (116.50 * 0.1538461538461538) + 109.93 * (1 - 0.1538461538461538)
= 17.92307692307692 + 109.93 * 0.8461538461538462
= 17.92307692307692 + 93.01769230769231
= 110.9407692307692
約等於 110.94
- 計算 EMA(26)
加權指數
K = 平滑因子 / (時間週期 + 1)
= Something / (N + 1)
= 2 / (26 + 1)
= 2 / 27
= 0.0740740740740741
EMA(26) = (今日收盤價 * 加權指數) + 昨日 EMA * (1 - 加權指數)
= (Today CP * K) + Yesterday EMA * (1 - K)
= (116.50 * 0.0740740740740741) + 110.24 * (1 - 0.0740740740740741)
= 8.629629629629633 + 110.24 * 0.9259259259259259
= 8.629629629629633 + 102.0740740740741
= 110.7037037037037
約等於 110.70
- 計算 DIF
DIF = EMA(12) - EMA(26)
= 110.94 - 110.70
= 0.24
- 計算 MACD
111/02/18
的 DIF
值為 0.24
111/02/17
的 DIF
值為 -0.30
111/02/16
的 DIF
值為 -0.54
111/02/15
的 DIF
值為 -0.88
111/02/14
的 DIF
值為 -1.15
111/02/11
的 DIF
值為 -1.43
111/02/10
的 DIF
值為 -1.92
111/02/09
的 DIF
值為 -2.71
111/02/08
的 DIF
值為 -3.49
加權指數
K = 平滑因子 / (時間週期 + 1)
= Something / (N + 1)
= 2 / (9 + 1)
= 2 / 10
= 0.2
EMA(DIF, 9) = (今日 DIF * 加權指數) + 昨日 MACD * (1 - 加權指數)
= (Today DIF * K) + Yesterday MACD * (1 - K)
= (0.24 * 0.2) + (-1.59) * (1 - 0.2)
= 0.048 + (-1.59) * 0.8
= 0.048 + (-1.272)
= -1.224
約等於 -1.22
MACD = EMA(DIF, 9)
= -1.22
範例資料
日期 | 收盤價 | EMA(12) | EMA(26) | DIF | MACD |
---|---|---|---|---|---|
111/02/18 | 116.50 | 110.94 | 110.70 | 0.24 | -1.22 |
111/02/17 | 112.00 | 109.93 | 110.24 | -0.30 | -1.59 |
111/02/16 | 112.50 | 109.56 | 110.09 | -0.54 | -1.91 |
111/02/15 | 111.00 | 109.02 | 109.90 | -0.88 | -2.25 |
111/02/14 | 110.50 | 108.66 | 109.81 | -1.15 | -2.59 |
111/02/11 | 112.00 | 108.33 | 109.76 | -1.43 | -2.95 |
111/02/10 | 114.00 | 107.66 | 109.58 | -1.92 | -3.33 |
111/02/09 | 112.00 | 106.51 | 109.23 | -2.71 | -3.69 |
111/02/08 | 112.50 | 105.51 | 109.00 | -3.49 | -3.93 |
111/02/07 | 108.00 | 104.24 | 108.72 | -4.48 | -4.04 |
111/01/26 | 98.60 | 103.56 | 108.78 | -5.22 | -3.93 |
111/01/25 | 95.10 | 104.46 | 109.60 | -5.13 | -3.61 |
111/01/24 | 99.90 | 106.17 | 110.76 | -4.59 | -3.22 |
111/01/21 | 99.00 | 107.30 | 111.63 | -4.32 | -2.88 |
111/01/20 | 104.00 | 108.81 | 112.64 | -3.82 | -2.52 |
111/01/19 | 104.00 | 109.69 | 113.33 | -3.64 | -2.20 |
111/01/18 | 106.50 | 110.72 | 114.07 | -3.35 | -1.84 |
111/01/17 | 105.50 | 111.49 | 114.68 | -3.19 | -1.46 |
111/01/14 | 107.50 | 112.58 | 115.41 | -2.83 | -1.03 |
111/01/13 | 105.00 | 113.51 | 116.05 | -2.54 | -0.58 |
111/01/12 | 108.00 | 115.05 | 116.93 | -1.88 | -0.09 |
111/01/11 | 112.00 | 116.34 | 117.64 | -1.31 | 0.36 |
111/01/10 | 111.50 | 117.12 | 118.10 | -0.97 | 0.77 |
111/01/07 | 113.50 | 118.15 | 118.62 | -0.48 | 1.21 |
111/01/06 | 114.50 | 118.99 | 119.03 | -0.04 | 1.63 |
111/01/05 | 115.00 | 119.81 | 119.40 | 0.41 | 2.05 |
111/01/04 | 115.50 | 120.68 | 119.75 | 0.93 | 2.46 |
111/01/03 | 114.50 | 121.62 | 120.09 | 1.54 | 2.85 |
範例資料: 陽明(2609) 111/02/18 ~ 111/01/03 個股股價行情
資料來源: https://stock.wearn.com/cdata.asp?Year=111&month=02&kind=2609