ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Financial Trading in R

Ver curso

Instrucciones del ejercicio

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

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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")
Editar y ejecutar código