【发布时间】:2016-10-25 12:14:27
【问题描述】:
我想在 quantstrat 中添加自定义指标,但该指标不是根据价格序列计算得出的。例如:
# Get SPY from Yahoo Finance
getSymbols("SPY", from = "2016-01-01", to = "2016-01-31", src = "yahoo", adjust = TRUE)
SPY <- SPY[,1:4]
#Create Indicator
set.seed(123)
indicator <- sample(seq(from = 0, to = 100, by = 5), size = nrow(SPY), replace = TRUE)
如何将该指标添加到我的策略中并从中产生信号?我所发现的只是添加指标的基本符号,但是是否可以添加已经计算的指标?
# Add a 5-day simple moving average indicator to your strategy
add.indicator(strategy = strategy.st,
# Add the SMA function
name = "SMA",
# Create a lookback period
arguments = list(x = quote(Cl(mktdata)), n = 5),
# Label your indicator SMA5
label = "SMA5")
【问题讨论】:
标签: r indicator quantstrat