[英]Overlay of multiple time series in Quantmod in R
I want to create a chart using chartSeries with two or more time series on the SAME chart (overlaying each other). 我想使用chartSeries在SAME图表上创建两个或两个以上时间序列的图表(彼此重叠)。 Bing/search doc have gotten me nowhere.
必应/搜索文档使我无所适从。 Seems like should be fairly easy, I tried addTA, but didn't work.
似乎应该很容易,我尝试了addTA,但是没有用。 I tried the following code.
我尝试了以下代码。
chartSeries(c(PSEC, ARCC), type = "line")
That resulted into this: (nevermind the fonts, the hell is the green blob?) 结果是:(不要介意字体,到底是绿色的斑点?)
The green blob is what you asked R to plot. 绿色斑点是您要求R绘制的。
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). c(PSEC, ARCC)
与rbind(PSEC, ARCC)
,后者创建单个OHLCVA对象,每个索引值具有两个观察值(一个用于PSEC,一个用于ARCC)。 You said you tried addTA
, but it "didn't work". 您说您尝试过
addTA
,但它“行不通”。 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. 这是一个使用
addTA
和相应的chart_Series
版本的chartSeries
调用。 Note that chart_Series
automatically handles the y-axis range for you. 请注意,
chart_Series
自动为您处理y轴范围。
> 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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.