首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >超卖/超买中的慢速交叉交叉

超卖/超买中的慢速交叉交叉
EN

Stack Overflow用户
提问于 2022-10-14 17:41:42
回答 1查看 28关注 0票数 0

我正在努力弄清楚如何定制我的策略,一个缓慢的斯托奇交叉。这是我目前的定义,当超买或超卖有交叉时,它会触发头寸。当"k“分别以+/-2的值横过/在"d”下时,我希望它更进一步。(这似乎改善了应计性)。知道怎么用松树编码吗?

代码语言:javascript
复制
//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")
EN

回答 1

Stack Overflow用户

发布于 2022-10-14 17:51:05

检查交叉/交叉并比较kd的值。

代码语言:javascript
复制
co = ta.crossover(k,d)
cu = ta.crossunder(k,d)

co_valid = co and ((k - d) > 2)
cu_valid = cu and ((d - k) > 2)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74072991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档