quantstrat (version 0.8.2)

add.signal: add a signal to a strategy


This adds a signal definition to a strategy object.


add.signal(strategy, name, arguments, parameters = NULL, label = NULL, ..., enabled = TRUE, indexnum = NULL, store = FALSE)


an object (or the name of an object) of type 'strategy' to add the signal to
name of the signal, must correspond to an R function
named list of default arguments to be passed to an signal function when executed
vector of strings naming parameters to be saved for apply-time definition,default NULL, only needed if you need special names to avoid argument collision
arbitrary text label for signal output, default NULL
any other passthru parameters
TRUE/FALSE whether the signal is enabled for use in applying the strategy, default TRUE
if you are updating a specific signal, the index number in the $signals list to update
TRUE/FALSE whether to store the strategy in the .strategy environment, or return it. default FALSE


if strategy was the name of a strategy, the name. It it was a strategy, the updated strategy.


Signals denote times at which the strategy may want to take action. Common signals types from the literature include crossovers, thresholds, or other interactions between your mktdata and your indicators.

if label is not supplied, NULL default will be converted to '.sig' if the signal function returns one named column, we use that, and ignore the label. If the signal function returns multiple columns, the label will be paste'd to either the returned column names or the respective column number.

See Also

applySignals add.indicator link{add.rule} sigComparison sigCrossover sigFormula sigPeak sigThreshold