【问题标题】:Pine script william rsi strategy not workingPine 脚本 william rsi 策略不起作用
【发布时间】:2020-05-16 22:51:35
【问题描述】:

当 percentR 超过 -20 和交叉 -80 但我的“何时”条件不起作用时,我想做多和做空

strategy("Williams %R", shorttitle="%R", format=format.price, precision=2)
length = input(title="Length", type=input.integer, defval=14)
_pr(length) =>
    max = highest(length)
    min = lowest(length)
    100 * (close - max) / (max - min)
percentR = _pr(length)
strategy.entry("buy", strategy.long, comment="buy", when=crossover(percentR, -20))
strategy.entry("sell", strategy.short, comment="sell", when=crossunder(percentR, -80))

【问题讨论】:

    标签: pine-script


    【解决方案1】:

    这似乎工作正常。我已将您的头寸规模更改为使用 2% 的权益。在一些合约价值较大的市场上,您可能需要增加启动资金才能建仓。

    //@version=4
    strategy("Williams %R", shorttitle="%R", format=format.price, precision=2, default_qty_type = strategy.percent_of_equity, default_qty_value = 2)
    length = input(title="Length", type=input.integer, defval=14)
    _pr(length) =>
        max = highest(length)
        min = lowest(length)
        100 * (close - max) / (max - min)
    percentR = _pr(length)
    strategy.entry("buy", strategy.long, comment="buy", when=crossover(percentR, -20))
    strategy.entry("sell", strategy.short, comment="sell", when=crossunder(percentR, -80))
    plot(percentR)
    hline(-20)
    hline(-80)
    plotchar(crossover(percentR, -20), "crossover(percentR, -20)", "▲", location.bottom, size = size.tiny)
    plotchar(crossunder(percentR, -80), "crossunder(percentR, -80)", "▼", location.top, size = size.tiny)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-04
      • 2021-07-27
      相关资源
      最近更新 更多