我正在努力弄清楚如何定制我的策略,一个缓慢的斯托奇交叉。这是我目前的定义,当超买或超卖有交叉时,它会触发头寸。当"k“分别以+/-2的值横过/在"d”下时,我希望它更进一步。(这似乎改善了应计性)。知道怎么用松树编码吗?
//Stochastic Inputs
length = input.int(14, minval=1)
OverBought = input(80)
OverSold = input(20)
smoothK = 3
smoothD = 3
k = ta.sma(ta.stoch(close, high, low, length), smoothK)
d = ta.sma(k, smoothD)
//Rule to define crossover /crossunder
co = ta.crossover(k,d)
cu = ta.crossunder(k,d)
if (not na(k) and not na(d))
//code to define if k is in overbought zone and k crossover d and enter a long trade
if (co and k < OverSold and is_uptrend)
strategy.entry("Long", strategy.long, comment="Long")
//code to define if k is in oversold zone and k crossunder d and enters a short trade
if (cu and k > OverBought and is_downtrend)
strategy.entry("Long", strategy.short, comment="Long")发布于 2022-10-14 17:51:05
检查交叉/交叉并比较k和d的值。
co = ta.crossover(k,d)
cu = ta.crossunder(k,d)
co_valid = co and ((k - d) > 2)
cu_valid = cu and ((d - k) > 2)https://stackoverflow.com/questions/74072991
复制相似问题