開始使用免費開始

使用 sigThreshold() - II

在這個練習中,你要根據 DVO 的某個臨界值實作一個離場訊號。雖然有兩個進場訊號必須同時成立(彼此皆非充分條件),但兩個離場訊號(本題與你先前實作的那個)各自都足以單獨觸發離場(在另一個存在時彼此皆非必要條件)。

在本題中,你會再次使用 sigThreshold(),這次要計算當 DVO_2_126 向上穿越 80 的臨界值時的情況。為了模擬 sigCrossover 訊號,請將 cross 設為 TRUE。將此訊號標記為 thresholdexit

本練習屬於課程

R 的金融交易

檢視課程

練習說明

  • 使用 add.signal() 加上一個 sigThreshold 訊號,指定 DVO_2_126 必須高於 80。
  • 這次將 cross 設為 TRUE
  • 將此訊號標記為 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 = "___")
編輯並執行程式碼