Last chance! 50% off unlimited learning
Sale ends in
SMA(x, n=10)
EMA(x, n=10, wilder=FALSE, ratio=NULL)
WMA(x, n=10, wts=1:n)
DEMA(x, n=10)
EVWMA(price, volume, n=10)
ZLEMA(x, n=10, ratio=NULL)
wts
vector must equal the
length of x
, or n
(the default).TRUE
, a Welles Wilder type EMA will be
calculated; see notes.wilder
in EMA)SMA
calculates the arithmetic mean of the series over the past n
observations.
EMA
calculates an exponentially-weighted mean, giving more weight to recent observations.
See Warning section below.
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.
DEMA
is calculated as: DEMA = 2 * EMA(x,n) - EMA(EMA(x,n),n)
.
EVWMA
uses volume to define the period of the 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.wilderSum
, which is used in calculating a Welles Wilder type MA.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"], 20)
zlema.20 <- ZLEMA(ttrc[,"Close"], 20)
## Example of short-term instability of 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 )
Run the code above in your browser using DataLab