EMA

指数移动平均值(Exponential Moving Average),简称EMA。是以指数式递减加权的移动平均。各数值的加权影响力随时间而指数式递减,越近期的数据加权影响力越重,但较旧的数据也给予一定的加权值。

计算

公式

[math]\displaystyle{ X_t }[/math]表示当前周期值,[math]\displaystyle{ S_t }[/math]表示当前周期的EMA值, [math]\displaystyle{ S_{t-1} }[/math]表示前一周期的EMA值:

EMA [math]\displaystyle{ S_t = \begin{cases} X_1, & {t=1} \\ α \times X_t + ( 1 - α ) \times S_{t-1}, & {t\gt 1} \end{cases} }[/math]
注:[math]\displaystyle{ α }[/math]为平滑指数常数,[math]\displaystyle{ 0\lt α \le 1 }[/math][math]\displaystyle{ α }[/math]可以用周期数N表示:[math]\displaystyle{ \alpha={2\over{N+1}} }[/math]

计算示例

假设有一组每天的收盘价为[math]\displaystyle{ X_9,X_8,X_7,X_6,X_5,X_4,X_3,X_2,X_1 }[/math],其中[math]\displaystyle{ X_9 }[/math]为今天的收盘价格。计算周期数N=2天,[math]\displaystyle{ \alpha={2\over{N+1}}=\frac{2}{3} }[/math],那么:

  • [math]\displaystyle{ S_9=\frac{2}{3}\times X_9 + \frac{1}{3} \times S_8 }[/math]
  • [math]\displaystyle{ S_8=\frac{2}{3}\times X_8 + \frac{1}{3} \times S_7 }[/math]
  • [math]\displaystyle{ S_7=\frac{2}{3}\times X_7 + \frac{1}{3} \times S_6 }[/math]
  • [math]\displaystyle{ ······ }[/math]
  • [math]\displaystyle{ S_2=\frac{2}{3}\times X_7 + \frac{1}{3} \times S_1 }[/math]
  • [math]\displaystyle{ S_1=X_1 }[/math]

公式推导

EMA是以指数式递减加权的移动平均。一组数值[math]\displaystyle{ P_2,P_3,P_4,P_5,P_6,\cdot\cdot\cdot }[/math],加权值为[math]\displaystyle{ 1,k,k^2,k^3,k^4,\cdot\cdot\cdot }[/math],其中k的值为[math]\displaystyle{ 0\le k\lt 1 }[/math],则[math]\displaystyle{ P_2 }[/math]的EMA值为:

[math]\displaystyle{ EMA(P_2)=\frac{1\times P_2+k\times P_3+k^2\times P_4+k^3\times P_5+k^4\times P_6+\cdot\cdot\cdot}{1+k+k^2+k^3+k^4+\cdot\cdot\cdot} }[/math]

这一组数值,新增加一个数值[math]\displaystyle{ P_1 }[/math],现在这组数值为:[math]\displaystyle{ P_1,P_2,P_3,P_4,P_5,\cdot\cdot\cdot }[/math],则[math]\displaystyle{ P_1 }[/math]的EMA值为:

[math]\displaystyle{ EMA(P_1)=\frac{1\times P_1+k\times P_2+k^2\times P_3+k^3\times P_4+k^4\times P_5+\cdot\cdot\cdot}{1+k+k^2+k^3+k^4+\cdot\cdot\cdot} }[/math]

然后将[math]\displaystyle{ EMA(P_2) }[/math]的值乘以k:

[math]\displaystyle{ k\times EMA(P_2)=\frac{k\times P_2+k^2\times P_3+k^3\times P_4+k^4\times P_5+k^5\times P_6+\cdot\cdot\cdot}{1+k+k^2+k^3+k^4+\cdot\cdot\cdot} }[/math]

接下来:

[math]\displaystyle{ \begin{align}EMA(P_1) &=\frac{1\times P_1}{1+k+k^2+k^3+k^4+\cdot\cdot\cdot}+\frac{k\times P_2+k^2\times P_3+k^3\times P_4+k^4\times P_5+\cdot\cdot\cdot}{1+k+k^2+k^3+k^4+\cdot\cdot\cdot} \\ &=\frac{1}{1+k+k^2+k^3+k^4+\cdot\cdot\cdot}\times P_1+k\times EMA(P_2) \\ &=\frac{(1+k+k^2+k^3+k^4+\cdot\cdot\cdot)-k\times(1+k+k^2+k^3+k^4+\cdot\cdot\cdot)}{1+k+k^2+k^3+k^4+\cdot\cdot\cdot}\times P_1+k\times EMA(P_2) \\ & =(1-k)\times P_1 +k\times EMA(P_2)\end{align} }[/math]


参数

在金融市场中,一般用于计算指数移动平均值的变量:

  • Close(收盘价)
  • Open(开盘价)
  • High(最高价)
  • Low(最低价)
  • Median Price(中间价):(high+low)/2
  • Typical Price(典型价格):(high+low+close)/3
  • Weighted Close(加权收盘价):(high+low+close+close)/4

一般用于计算的时间周期:

  • 星期
  • 4小时
  • 30分钟

应用

资源

相关网站


参考文献