Get startedGet started for free

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.

This exercise is part of the course

Financial Trading in R

View Course

Exercise 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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 = "___")
Edit and Run Code