英文參考:http://www.incrediblecharts.com/indicators/exponential_moving_average.phpphp
Exponential moving averages are recommended as the most reliable of the basic moving average types. They provide an element of weighting, with each preceding day given progressively less weighting. Exponential smoothing avoids the problem encountered with simple moving averages, where the average has a tendency to "bark twice": once at the start of the moving average period and again in the opposite direction, at the end of the period. Exponential moving average slope is also easier to determine: the slope is always down when price closes below the moving average and always up when price is above. echarts
To calculate an exponential moving average (EMA):less
If we recalculate the earlier table we see that the exponential moving average presents a far smoother trend:ide
Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Price ($) | 16 | 17 | 17 | 10 | 17 | 18 | 17 | 17 | 17 |
33.3% (or 1/3) EMA | 16.3 | 16.5 | 14.4 | 15.2 | 16.2 | 16.4 | 16.6 | 16.8 |
指數移動平均被認爲是最可靠的基本移動平均類型。每一個抽樣數據都附有以一個權重值,相鄰的兩個權重值向前遞減(也就是前一個權重值比當前權重值減一)。指數移動平均的指數平滑避免了’通常移動平均‘的某些問題,好比通常的移動平均會有「兩次跳躍(bark twice)」的現象,從而扭曲數據與實際狀況的符合程度。this
好比:spa
To calculate a 5 day simple moving average ("SMA"), take the sum of the last 5 days prices and divide by 5.3d
Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Price ($) | 16 | 17 | 17 | 10 | 17 | 18 | 17 | 17 | 17 |
5 Day SMA | 15.4 | 15.8 | 15.8 | 15.8 | 17.2 |
從上面的表格咱們能夠看到,在第9天,簡單移動平均結果是17.2,與第8天的簡單移動平均15.8相比有一個較大的跳躍,而第八、9兩天的實際數據爲1七、17並無變化。在第4天時的數據不單單引發當前數值上的降低,並且還對第9天的簡單移動平均形成了扭曲,也就是前面說的那個條約。這就是所謂的「bark twice」。也就是說原始數據一次脈衝式跳躍,會致使後面數據的跳躍,而且兩次跳躍的方向相反,從而不能很好描述原始數據的變化趨勢。所以纔有人提出了指數平滑移動平均線Exponential Moving Average,簡稱EMA。orm
EXPMA(Exponential Moving Average)譯指數平滑移動平均線,簡稱EMA,blog
求當日價格X的N日指數平滑移動平均,在股票公式中通常表達爲:EMA(X,N),其中X爲當日收盤價,N爲天數。它真正的公式表達是:當日指數平均值=平滑係數*(當日指數值-昨日指數平均值)+昨日指數平均值;平滑係數=2/(週期單位+1);由以上公式推導開,獲得:EMA(N)=2*X/(N+1)+(N-1)*EMA(N-1)/(N+1);ip
但是這個公式的前提是要知道前一天的EMA,若是已知N天的價格,我想求取連續N天的EMA,怎麼根據這個N個價格計算EMA呢?根據概括推算獲得公式以下: