ComeçarComece de graça

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.

Este exercício faz parte do curso

Financial Trading in R

Ver curso

Instruções do exercício

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

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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 = "___")
Editar e executar o código