Description Usage Arguments Details Value Examples
applyIndicators
will take the mktdata
object,
and will apply each indicator specified in the strategy
definition to it.
1 | applyIndicators(strategy, mktdata, parameters = NULL, ...)
|
strategy |
an object of type 'strategy' to add the indicator to |
mktdata |
an xts object containing market data. depending on indicators, may need to be in OHLCV or BBO formats |
parameters |
named list of parameters to be applied during evaluation of the strategy |
... |
any other passthru parameters |
If the indicator function returns an xts object or a vector
of the same length as mktdata, the columns created by the
indicator function will be added to the mktdata object via
cbind
.
If the indicator function returns multiple columns, the
label will be paste
'd to the end of either
the returned column names or the respective column number
when applying it to mktdata
.
If the indicator returns some more complexobject, it will
be added to a list in the $indicators slot inside the
applyStrategy
execution frame. If you want
your indicators to return a more complex object, (such as a
model specification and output from a regression), be
advised that your signal generator, and potentially your
rule function, will need to understand, anticipate, and
know how to manipulate the internal strategy frame.
mktdata
with indicators colums added.
1 2 3 4 5 6 7 8 9 | ## Not run:
strategy("example", store=TRUE)
getSymbols("SPY", src='yahoo')
add.indicator('example', 'SMA', arguments=list(x=quote(Ad(SPY)), n=20))
str(getStrategy('example')$indicators)
out <- applyIndicators('example', SPY)
tail(out)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.