Ich möchte benutzerdefinierte Indikator in quantstrat hinzufügen, aber dieser Indikator ist nicht aus Preis-Serie berechnet. Zum Beispiel:Hinzufügen Indikator Quantstrat R
# 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)
Wie kann ich diesen Indikator zu meiner Strategie hinzufügen und Signale daraus generieren? Alles, was ich gefunden habe, ist diese Grundnotation des Hinzufügens von Indikatoren, aber ist es da, um bereits berechnete Indikatoren hinzuzufügen?
# 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")