[R-sig-finance] Question about Exponential Weighted Moving Average
(EWMA) in rmetrics
German G. Creamer
gcreamer at cs.columbia.edu
Sun Nov 21 00:08:25 CET 2004
Hi all,
I
I am trying to use the macd function. It is used with cdoTA which calls
macdTA and this calls emaTA. However arguments of emaTA do not match those
requested at macdTA.
I wonder if there is another function of emaTA or EWMA that can be used
with macd. A similar problem I found with the file funSeries.R.
Thanks
German Creamer
These are the function definitions at fSeries:
cdoTA <-
function (x, lag1, lag2, lag3)
{
macdTA(x, lag1, lag2) - cdsTA(x, lag1, lag2, lag3)
}
> macdTA
function (x, lag1, lag2)
{
emaTA(x, lag1) - emaTA(x, lag2)
}
Do not correspond to:
> emaTA
function (x, lambda, startup = 0)
{
if (lambda >= 1)
lambda = 2/(lambda + 1)
if (startup == 0)
startup = floor(2/lambda)
if (lambda == 0) {
xema = rep(mean(x), length(x))
}
if (lambda > 0) {
xlam = x * lambda
xlam[1] = mean(x[1:startup])
xema = filter(xlam, filter = (1 - lambda), method = "rec")
}
xema
}
More information about the R-sig-finance
mailing list