applyIndicators

0th

Percentile

apply the indicators in the strategy to arbitrary market data

applyIndicators will take the mktdata object, and will apply each indicator specified in the strategy definition to it.

Usage
applyIndicators(strategy, mktdata, parameters = NULL, ...)
Arguments
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
Details

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.

Value

mktdata with indicators colums added.

Aliases
  • applyIndicators
Examples
## 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)
Documentation reproduced from package quantstrat, version 0.8.2, License: GPL-3

Community examples

Looks like there are no examples yet.