Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Financial Trading in R

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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")
Code bewerken en uitvoeren