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

Sávio Ramos savio.debian at gmail.com
Thu May 24 04:32:54 CEST 2012


2012/5/23 R. Michael Weylandt <michael.weylandt at gmail.com>

> Not runnable exactly as is.... where does the for loop have its close
> brace?
>
> This works fine for me:
>
> getSymbols("SPY", from = "1990-01-01")
> y <- to.weekly(SPY)
> chartSeries(y, type = "candlesticks", multi.col = TRUE, theme =
> "white", subset = 'last 54 months', name = "SPY")
> addMACD(fast = 12, slow = 26, signal = 9, type = "EMA", histogram = TRUE)
> saveChart('pdf',width=25,height=13)
>
> so try it for you.
>
> I tried the code above and it works fine.


> Your data seems to work for me if I close the loop after MACD. Can you
> display the error message or say more about why you think it doesn't
> work?
>
> You can see in the next file attached that MACD is not added to graphic.

There is a warning message saying this:

1: In last.xts(c(86.99, 81.46, 82.11, 67.7, 75.02, 78.95, 82.59, 84.3,  :
  requested length is greater than original
2: In last.xts(c(59.25, 56.48, 56.1, 48, 49.01, 53.17, 53.4, 58.99,  :
  requested length is greater than original


P.S. I pasted the code missing the close of the loop. In the original code
the loop is closed.



> Michael
>
> On Tue, May 22, 2012 at 10:58 PM, Sávio M. Ramos <savio.debian at gmail.com>
> wrote:
> > Hi,
> >
> > addMACD don't work. I am doing something wrong or it is a bug.
> >
> > The code:
> >
> > 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)
> > addMACD(fast = 12, slow = 26, signal = 9, type = "EMA", histogram = TRUE)
> > saveChart('pdf',width=25,height=13)
> >
> >
> > The two files is attached.
> >
> > []'s
> > --
> > Sávio M Ramos
> > Arquiteto, Rio, RJ
> > Só uso Linux desde 2000
> > www.debian.org
> >
> >
> > _______________________________________________
> > R-SIG-Finance at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20120523/7b00939e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PETR4.csv.pdf
Type: application/pdf
Size: 16726 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20120523/7b00939e/attachment.pdf>


More information about the R-SIG-Finance mailing list