开始使用免费开始使用

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.

本练习是课程的一部分

Financial Trading in R

查看课程

练习说明

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

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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 = "___")
编辑并运行代码