Specifying sigval in add.rule()
Now that you've specified the column containing the relevant signal in your strategy, the next argument to specify in add.rule()
is sigval
, or the value that your signal should take to trigger the rule.
Remember that all signal outputs are either 1s or 0s. Effectively, a signal is either "on" or "off" at any given time. For our purposes, this is equivalent to two possible logical values: TRUE
or FALSE
. When specifying sigval
in your add.rule()
command, you need to indicate whether the rule is triggered when the signal value is TRUE
or FALSE
.
To proceed with the new exit rule in your strategy, you will want to specify that a transaction should occur when filterexit
is equal to TRUE
. The add.rule()
command from your previous exercise is available in your workspace.
This exercise is part of the course
Financial Trading in R
Exercise instructions
- Set the
sigval
argument inadd.rule()
equal toTRUE
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Fill in the sigval argument in add.rule()
add.rule(strategy.st, name = "ruleSignal",
arguments = list(sigcol = "filterexit", sigval = ___, orderqty = "all",
ordertype = "market", orderside = "long",
replace = FALSE, prefer = "Open"),
type = "exit")