LoslegenKostenlos loslegen

Specifying replace in add.rule()

In quantstrat, the replace argument specifies whether or not to ignore all other signals on the same date when the strategy acts upon one signal. This is generally not a desired quality in a well-crafted trading system. Therefore, for your exit rule, you should set replace to FALSE.

Furthermore, you will be working with a new rule. Previously, the exit rule you worked with was when the market environment was no longer conducive to a trade. In this case, you will be working with a rule that sells when the DVO has crossed a certain threshold. In particular, you will be working with the thresholdexit rule now.

Diese Übung ist Teil des Kurses

Financial Trading in R

Kurs anzeigen

Anleitung zur Übung

  • Set the replace input inside the arguments input to FALSE.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Fill in the replace argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "thresholdexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "market", orderside = "long", 
                        replace = ___, prefer = "Open"), 
         type = "exit")
Code bearbeiten und ausführen