我似乎无法使用ttr指示灯与eventer.apply()从xts中使用direclty。请帮助我弄清楚我做错了什么。

> require(TTR)
> require(quantmod)
> require(xts)
> data(sample_matrix)

> period.apply(sample_matrix, endpoints(sample_matrix,"weeks"), RSI)

Error in EMA(c(NA, 0.190714286249097, 0.190459011271606, 0, 0, 0, NA,  : 
  Invalid 'n'
.

我也首先尝试了生成的acodetagcode,但它没有帮助。

有帮助吗?

解决方案

Based on the comments to your question, I think you want something like this:

> RSI(Cl(to.period(sample_matrix, "weeks", 2)),4)
               [,1]
2007-01-07       NA
2007-01-21       NA
2007-02-04       NA
2007-02-18       NA
2007-03-04 58.42659
2007-03-18 40.25955
2007-04-01 27.12793
2007-04-15 50.26745
2007-04-29 38.97652
2007-05-13 22.03943
2007-05-27 28.75952
2007-06-10 22.21261
2007-06-24 21.58207
2007-06-30 41.69338
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top