【发布时间】:2020-11-09 07:49:35
【问题描述】:
我正在尝试为随机进入/退出建立一个简单的策略。 我几乎从内置指标中复制粘贴了随机公式。 我遇到的问题是长短布尔信号似乎有一些问题。
虽然使用“goshort”布尔值的 k >= 75 交叉对我来说非常好,但当我尝试使用“golong”布尔值评估 k
我在下面的代码中将 'golong' 布尔值保留为与 k
//@version=4
strategy("Stochastic Slow Strategy", overlay=true)
periodK = input(8, title="K", minval=1)
periodD = input(3, title="D", minval=1)
smoothK = input(3, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
OverSold = 20
OverBought = 80
co = k >= d and k[1] <= d[1] ? true : false
cu = k <= d and k[1] >= d[1] ? true : false
golong=co and k <= 75? true: false // <--This is the line where I have a problem
goshort=cu and k >= 75? true: false
strategy.entry("Sell", strategy.short, comment="Sell", when=goshort==true)
strategy.entry("Buy", strategy.long, comment="Buy", when=golong==true)
【问题讨论】: