[R-SIG-Finance] Can't addMACD(). Is it a bug?

G See gsee000 at gmail.com
Thu May 24 04:47:56 CEST 2012


On Wed, May 23, 2012 at 9:32 PM, Sávio Ramos <savio.debian at gmail.com> wrote:
>
> You can see in the next file attached that MACD is not added to graphic.

Sávio,

Try wrapping plot around addMACD.  So, your code would look like this:

require(quantmod)
lista <- c("PETR4.csv", "VALE3.csv")
for (i in lista){
    x <- as.xts(read.zoo(i, sep=",", format="%Y-%m-%d", header=TRUE))
    y <- to.weekly(x)
    chartSeries(y, type="candlesticks", multi.col=TRUE, theme="white",
subset='last 54 months', name=i)
    plot(addMACD(fast = 12, slow = 26, signal = 9, type = "EMA",
histogram = TRUE))
}

HTH,
Garrett



More information about the R-SIG-Finance mailing list