MovingAverages(TTR)
MovingAverages()所属R语言包:TTR
Moving Averages
移动平均线
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Calculate various moving averages (MA) of a series.
计算了一系列不同的移动平均线(MA)。
用法----------Usage----------
SMA(x, n=10)
EMA(x, n=10, wilder=FALSE, ratio=NULL)
WMA(x, n=10, wts=1:n)
DEMA(x, n=10, v=1, wilder=FALSE, ratio=NULL)
EVWMA(price, volume, n=10)
ZLEMA(x, n=10, ratio=NULL)
VWMA(price, volume, n=10)
VWAP(price, volume, n=10)
VMA(x, w, ratio=1)
参数----------Arguments----------
参数:x
Price, volume, etc. series that is coercible to xts or matrix.
价格,数量,等系列产品,为强制XTS或矩阵。
参数:price
Price series that is coercible to xts or matrix.
价格XTS或矩阵转换成系列。
参数:volume
Volume series that is coercible to xts or matrix, that corresponds to price series, or a constant. See Notes.
卷系列为强制XTS或矩阵,对应的价格序列,或一个常数。见注解。
参数:n
Number of periods to average over.
平均周期数。
参数:v
The 'volume factor' (a number in [0,1]). See Notes.
体积系数“([0,1])。见注解。
参数:w
Vector of weights (in [0,1]) the same length as x.
向量的重量(在[0,1])的长度相同x。
参数:wts
Vector of weights. Length of wts vector must equal the length of x, or n (the default).
向量的重量。 wts矢量的长度必须等于x的长度或n(默认值)。
参数:wilder
logical; if TRUE, a Welles Wilder type EMA will be calculated; see notes.
逻辑,如果TRUE,威尔斯怀尔德类型EMA计算;见注释。
参数:ratio
A smoothing/decay ratio. ratio overrides wilder in EMA, and provides additional smoothing in VMA.
平滑/衰减率。 ratio覆盖wilderEMA,并提供额外的平滑VMA。
Details
详细信息----------Details----------
SMA calculates the arithmetic mean of the series over the past n observations.
SMA计算的算术平均值,该系列在过去n观察。
EMA calculates an exponentially-weighted mean, giving more weight to recent observations. See Warning section below.
EMA计算指数加权平均,让更多的重量,最近的观测。见警告一节。
WMA is similar to an EMA, but with linear weighting if the length of wts is equal to n. If the length of wts is equal to the length of x, the WMA will use the values of wts as weights.
WMA是类似均线,但,线性加权长度的wts等于n的。如果长度wts是x,WMA使用wts作为权重值的长度相等。
DEMA is calculated as: DEMA = (1 + v) * EMA(x,n) - EMA(EMA(x,n),n) * v (with the corresponding wilder and ratio arguments).
DEMA的计算公式为:DEMA = (1 + v) * EMA(x,n) - EMA(EMA(x,n),n) * v(对应的wilder和ratio参数)。
EVWMA uses volume to define the period of the MA.
EVWMA使用量来定义期间的MA。
ZLEMA is similar to an EMA, as it gives more weight to recent observations, but attempts to remove lag by subtracting data prior to (n-1)/2 periods (default) to minimize the cumulative effect.
ZLEMA是类似的EMA,因为它提供了更多的重量,最近的观测,但尝试删除数据减去之前(n-1)/2期间(默认),以尽量减少累积效应的滞后。
VWMA and VWAP calculate the volume-weighted moving average price.
VWMA和VWAP计算量加权移动平均价格。
VMA calculate a variable-length moving average based on the absolute value of w. Higher (lower) values of w will cause VMA to react faster (slower).
VMA计算一个可变长度的移动平均的基础上的绝对值w。较高(低)值w会导致VMA反应快(慢)。
值----------Value----------
A object of the same class as x or price or a vector (if try.xts fails) containing the columns:
一个对象的同一类x或price或包含的列向量(try.xts如果失败):
参数:SMA
Simple moving average.
简单的移动平均线。
参数:EMA
Exponential moving average.
指数移动平均线。
参数:WMA
Weighted moving average.
加权移动平均线。
参数:DEMA
Double-exponential moving average.
双指数移动平均线。
参数:EVWMA
Elastic, volume-weighted moving average.
有弹性,成交量加权移动平均线。
参数:ZLEMA
Zero lag exponential moving average.
零滞后指数移动平均线。
参数:VWMA
Volume-weighed moving average (same as VWAP).
成交量加权的移动平均(相同VWAP)。
参数:VWAP
Volume-weighed average price (same as VWMA).
成交量加权的平均价(相同VWMA)。
参数:VWA
Variable-length moving average.
可变长度的移动平均线。
警告----------Warning ----------
Some indicators (e.g. EMA, DEMA, EVWMA, etc.) are calculated using the indicators' own previous values, and are therefore unstable in the short-term. As the indicator receives more data, its output becomes more stable. See example below.
有些指标(如EMA,DEMA,EVWMA,等)计算指标“自己以前的值,因此在短期不稳定的。作为指示器接收更多的数据,它的输出变得更稳定。见下面的例子。
注意----------Note----------
For EMA, wilder=FALSE (the default) uses an exponential smoothing ratio of 2/(n+1), while wilder=TRUE uses Welles Wilder's exponential smoothing ratio of 1/n.
对于EMA,wilder=FALSE(默认)采用指数平滑2/(n+1)比,wilder=TRUE使用威尔斯怀尔德的指数平滑的比例1/n。
Since WMA can accept a weight vector of length equal to the length of x or of length n, it can be used as a regular weighted moving average (in the case wts=1:n) or as a moving average weighted by volume, another indicator, etc.
由于WMA可以接受的长度等于x或长度n,它可以被用来作为一个经常性的加权移动平均(的情况下wts=1:n的长度权重向量)或按体积加权的移动平均值,另一个指标等
Since DEMA allows adjusting v, it is technically Tim Tillson's generalized DEMA (GD). When v=1 (the default), the result is the standard DEMA. When v=0, the result is a regular EMA. All other values of v return the GD result. This function can be used to calculate Tillson's T3 indicator (see example below). Thanks to John Gavin for suggesting the generalization.
由于DEMA允许调整v,它在技术上添Tillson的广义DEMA(GD)。当v=1(默认值),结果是标准的DEMA。当v=0,结果是一个普通的EMA。所有其他值v返回GD结果。此功能可用于计算Tillson的T3指标(见下面的例子)。感谢约翰·加文建议的推广。
For EVWMA, if volume is a series, n should be chosen so the sum of the volume for n periods approximates the total number of outstanding shares for the security being averaged. If volume is a constant, it should represent the total number of outstanding shares for the security being averaged.
对于EVWMA,如果volume是一个系列,n应选择这样的体积n期间的总和相若的安全性是流通股总数的平均。如果volume是一个常数,它代表已发行股份总数的平均安全。
(作者)----------Author(s)----------
Joshua Ulrich
参考文献----------References----------
http://www.fmlabs.com/reference/ExpMA.htm<br> http://www.fmlabs.com/reference/WeightedMA.htm<br> http://www.fmlabs.com/reference/DEMA.htm<br> http://www.fmlabs.com/reference/T3.htm<br> http://linnsoft.com/tour/techind/evwma.htm<br> http://www.fmlabs.com/reference/ZeroLagExpMA.htm<br> http://www.fmlabs.com/reference/VIDYA.htm<br>
参见----------See Also----------
See wilderSum, which is used in calculating a Welles Wilder type MA.
见wilderSum,它是用来在计算威尔斯怀尔德型麻萨诸塞州。
实例----------Examples----------
data(ttrc)
ema.20 <- EMA(ttrc[,"Close"], 20)
sma.20 <- SMA(ttrc[,"Close"], 20)
dema.20 <- DEMA(ttrc[,"Close"], 20)
evwma.20 <- EVWMA(ttrc[,"Close"], ttrc[,"Volume"], 20)
zlema.20 <- ZLEMA(ttrc[,"Close"], 20)
## Example of Tim Tillson's T3 indicator[#示例添Tillson的T3指标]
T3 <- function(x, n=10, v=1) DEMA(DEMA(DEMA(x,n,v),n,v),n,v)
t3 <- T3(ttrc[,"Close"])
## Example of short-term instability of EMA[#示例的短期不稳定的EMA]
## (and other indicators mentioned above)[#(与上面提到的其他指标)]
x <- rnorm(100)
tail( EMA(x[90:100],10), 1 )
tail( EMA(x[70:100],10), 1 )
tail( EMA(x[50:100],10), 1 )
tail( EMA(x[30:100],10), 1 )
tail( EMA(x[10:100],10), 1 )
tail( EMA(x[ 1:100],10), 1 )
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|