I would like to add custom indicator in quantstrat, but this indicator isn't calculated from price series. For example:
# 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)
How can I add that indicator to my strategy and produce signals from it? All I have found is this basic notation of adding indicators, but is there away to add already calculated indicators?
# 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")