[R] quantmod's addTA plotting functions

From: Russ Abbott <russ.abbott_at_gmail.com>
Date: Wed, 04 May 2011 23:47:00 -0700


Hi,

I'm having trouble with quantmod's addTA plotting functions. They seem to work fine when run from the command line. But when run inside a function, only the last one run is visible. Here's an example.

test.addTA <- function(from = "2010-06-01") {

    getSymbols("^GSPC", from = from)

    GSPC.close     <- GSPC[,"GSPC.Close"]
    GSPC.EMA.3   <- EMA(GSPC.close, n=3, ratio=NULL)
    GSPC.EMA.10  <- EMA(GSPC.close, n=10, ratio=NULL)
    chartSeries(GSPC.close, theme=chartTheme('white'), up.col="black", dn.col="black")

    addTA(GSPC.EMA.3, on = 1, col = "#0000ff")     addTA(GSPC.EMA.10, on = 1, col = "#ff0000")     # browser()
}

When I run this, GSPC.close always appears. But only GSPC.EMA10 appears on the plot along with it. If I switch the order of the addTA calls, only GSPC.EMA3 appears. If I uncomment the call to browser() neither appears when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and GSPC.EMA10 manually, and let the function terminate. All intended plots are visible after the function terminates. So it isn't as if one wipes out the other. This shows that it's possible to get all three lines on the plot, but I can't figure out how to do it without manual intervention. Any suggestions are appreciated.

Thanks.

*-- Russ *

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 05 May 2011 - 06:50:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 11:40:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive