CommencerCommencer gratuitement

Using sigThreshold() - II

In this exercise, you will implement a signal to exit a position given a certain threshold value of the DVO. While there are two entry signals that are both necessary but neither sufficient on its own, the two exit signals (this one and the one you implemented in an earlier exercise) are both sufficient on their own (but neither necessary in the existence of the other) to exit a position.

In this exercise, you will again use sigThreshold(), this time counting when the DVO_2_126 crosses above a threshold of 80. To mimic a sigCrossover signal, set cross equal to TRUE Label this signal thresholdexit.

Cet exercice fait partie du cours

Financial Trading in R

Afficher le cours

Instructions

  • Use add.signal() to add a sigThreshold signal specifying that the DVO_2_126 must be above 80.
  • This time, set cross equal to TRUE.
  • Label this signal thresholdexit.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Add a sigThreshold signal to your strategy that specifies that DVO_2_126 must cross above 80 and label it thresholdexit
add.signal(strategy.st, name = "___", 
           
           # Reference the column of DVO_2_126
           arguments = list(column = "___", 
                            
                            # Set a threshold of 80
                            threshold = ___, 
                            
                            # The oscillator must be greater than 80
                            relationship = "___", 
                            
                            # We are interested only in the cross
                            cross = ___), 
           
           # Label it thresholdexit
           label = "___")
Modifier et exécuter le code