CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Financial Trading in R

Afficher le cours

Instructions

  • Set the sigval argument in add.rule() equal to TRUE.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de 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")
Modifier et exécuter le code