移動平均
维基百科,自由的百科全书
移動平均是技術分析其中一種分析时间序列數據的工具。最常見的是利用股價、回報或交易量等變數計算出移動平均。
移動平均可撫平短期波動,將長線趨勢或周期顯現出來。數學上,移動平均可視為一種卷积。
目录 |
[编辑] 簡單移動平均
簡單移動平均(SMA)是之前n個數值的未作加權算術平均。例如,收市價的10日簡單移動平均指之前10日收市價的平均數。設收市價為p1至pn,則方程式為:
當計算連續的數值,一個新的數值加入,同時一個舊數值剔出,所以無需每次都重新逐個數值加起來:
在技術分析中,有幾個n的數值較為普遍,如10日、40日、200日,視乎分析時期長短而定。投資者冀從移動平均線的圖表中分辨出支持位或阻力位。
[编辑] 加權移動平均
加權移動平均(WMA)指計算平均時個別數據乘以不同數值,在技術分析中,n日WMA的最近期一個數值乘以n、次近的乘以n-1,如此類推,一直到0:
計算連續數值時,方程式如下:
- 今日總和 = 昨日總和 + p1 − pn + 1
- 分子 = N = 昨日分子 + np1 − 昨日總和
留意分母為三角形數,方程式為
右圖顯示出加權是隨日子遠離而算術式遞減,直至0。
[编辑] 指數移動平均
指數移動平均(EMA或EWMA)是以指數式遞減加權的移動平均。各數值的加權而隨時間而指數式遞減,越近期的數據加權越重,但較舊的數據也給予一定的加權。右圖是一例子。
加權的程度以常數α決定,α數值介乎0至1,. α may be expressed as a percentage, so a smoothing factor of 10% is equivalent to α=0.1. Alternately, α may be expressed in terms of N time periods, where . For example, N=19 is equivalent to α=0.1.
The observation at a time period t is designated Yt, and the value of the EMA at any time period t is designated St. S1 is undefined. S2 may be initialized in a number of different ways, most commonly by setting S2 to Y1, though other techniques exist, such as setting S2 to an average of the first 4 or 5 observations. The prominence of the S2 initialization's effect on the resultant moving average depends on α; smaller α values make the choice of S2 relatively more important than larger α values, since a higher α discounts older observations faster.
The formula for calculating the EMA at time periods t≥2 is[1]
This formulation is according to Hunter (1986)[2]; an alternate approach by Roberts (1959) uses Yt in place of Yt-1[3]
This formula can also be expressed in technical analysis terms as follows, showing how the EMA steps towards the latest price, but only by a proportion of the difference (each time),[4]
Expanding out EMAyesterday each time results in the following power series, showing how the weighting factor on each price p1, p2, etc, decrease exponentially,
In theory this is an infinite sum, but because 1-α is less than 1, the terms become smaller and smaller, and can be ignored once small enough. The denominator approaches 1/α, and that value can be used instead of adding up the powers, provided one is using enough terms that the omitted portion is negligible.
The N periods in an N-day EMA only specifies the α factor. It isn't a stopping point for the calculation in the way N is in an SMA or WMA. The first N days in an EMA do represent about 86% of the total weight in the calculation though.
The power formula above gives a starting value for a particular day, after which the successive days formula shown first can be applied.
The question of how far back to go for an initial value depends, in the worst case, on the data. If there are huge p price values in old data then they'll have an effect on the total even if their weighting is very small. If one assumes prices don't vary too wildly then just the weighting can be considered, and work out how much weight is omitted by stopping after say k terms. This is , which is , ie. a fraction out of the total weight.
Thus if the aim was to have 99.9% of the weight then many terms should be used. And what's more it can be shown approaches as N increases, so this simplifies to (roughly) for this example 99.9% weight.
[编辑] J. Welles Wilder
Noted technical analyst J. Welles Wilder uses a different form for specifying the period of an EMA. For say 14 days he writes[5]
So α=1/N rather than α=2/(N+1) as described above. The calculation and properties are all the same, it's just a different reckoning of the rate of smoothing. Clearly care must be taken with which is intended. A conversion can be easily made, for instance 14-days from Wilder is equivalent to 27-days in the above (conversion 2N-1).
The formula for calculating the EMA at time periods t≥2 is[2]
[编辑] Other weightings
Other weighting systems are used occasionally – for example, a volume weighting will weight each time period in proportion to its trading volume.
There are weighting systems designed using a combination of moving averages: The DEMA indicator (and TEMA indicator (Triple Exponential Moving Average) are unique composites of a single exponential moving average, a double exponential moving average, and in the latter case a triple exponential moving average that provides less lag than either of the three components individually. They were originally introduced January 1994 by Patrick Mulloy.
The TRIX indicator uses a triple-EMA in its calculation. This ends up as just a certain set of weights on past data, and a set quite different to a plain EMA actually.
[编辑] 參閱
- MACD
[编辑] 參考資料
- ↑ NIST/SEMATECH e-Handbook of Statistical Methods: Single Exponential Smoothing at the National Institute of Standards and Technology
- ↑ NIST/SEMATECH e-Handbook of Statistical Methods: Single Exponential Smoothing at the National Institute of Standards and Technology
- ↑ NIST/SEMATECH e-Handbook of Statistical Methods: EWMA Control Charts at the National Institute of Standards and Technology
- ↑ Moving Averages page at StockCharts.com
- ↑ Relative Strength Index construction at IncredibleCharts.com