I want to create a chart using chartSeries with two or more time series on the SAME chart (overlaying each other). Bing/search doc have gotten me nowhere. Seems like should be fairly easy, I tried addTA, but didn't work. I tried the following code.

chartSeries(c(PSEC, ARCC), type = "line")

That resulted into this: (nevermind the fonts, the hell is the green blob?)

enter image description here

有帮助吗?

解决方案

The green blob is what you asked R to plot. c(PSEC, ARCC) is the same as rbind(PSEC, ARCC), which creates a single OHLCVA object with two observations per index value (one for PSEC, one for ARCC). You said you tried addTA, but it "didn't work". Saying something "doesn't work" does not help people help you, especially when you don't even show the code that "doesn't work".

Here's a chartSeries call that uses addTA, and a corresponding chart_Series version. Note that chart_Series automatically handles the y-axis range for you.

> chartSeries(Cl(PSEC), TA="addTA(Cl(ARCC), on=1)")
> chart_Series(Cl(PSEC), TA="add_TA(Cl(ARCC), on=1)")

其他提示

Your data, if it is not daily, could easily look like a green blob.

For example, if that's minute-by-minute prices, I'd expect it to look like this upon visual inspection.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top