實作指標 - III
在金融市場中,目標是低買高賣。RSI 尤其在期間很短(例如 2 或 3)時,能預測價格是否已經出現足夠的回檔。
在這裡,你將建立一個 3 期 RSI(RSI 3),讓你更熟悉如何實作已預先撰寫好的指標。quantstrat 與 quantmod 套件已為你載入。
本練習屬於課程
R 的金融交易
練習說明
- 在既有的策略
strategy.st上使用add.indicator()。請依照前面練習的範例程式碼。 - 將 RSI 函式提供給
name參數。 - 指定 RSI 所需的參數,使用
mktdata的收盤價,以及回看期n為 3 天。別忘了使用quote()函式! - 將新指標標記為
"RSI_3"。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Add an RSI 3 indicator to strategy.st
add.indicator(strategy = strategy.st,
# Add the RSI 3 function
name = ___,
# Create a lookback period
arguments = list(___),
# Label your indicator RSI_3
label = ___)