使用 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 = "___")