【问题标题】:Regarding a buystop order which is not executed in the next candle in pine script关于在 pine 脚本的下一个蜡烛中未执行的买入止损订单
【发布时间】:2021-09-05 14:27:06
【问题描述】:

我试图回测突破策略。

问题是当遇到longCondition 时,会触发buystop。但是,如果未在下一根蜡烛中完成此购买订单,则会在以下蜡烛中寻找信号。一旦在下一根蜡烛中没有满足,如何停止寻找满足感?我尝试使用策略。取消,但如果在下一个蜡烛中未履行,则无法取消订单履行。

hh = highest(high,13)
longCondition=close >= hh[1]
if (longCondition)
    StopPrice= high+syminfo.mintick
    LimitPrice= StopPrice+(4*syminfo.mintick)
    strategy.entry("13 days breakout",long=true, stop=StopPrice, limit= LimitPrice)

【问题讨论】:

    标签: pine-script back-testing


    【解决方案1】:

    通过将 bar_index 存储在某个变量中来检查自您的长期条件以来经过了多少条柱线。

    var bars = bar_index
    if (longCondition)
        StopPrice= high+syminfo.mintick
        LimitPrice= StopPrice+(4*syminfo.mintick)
        strategy.entry("13 days breakout",long=true, stop=StopPrice, limit= LimitPrice)
        bars := bar_index    
        
    if (bar_index - bars) >=2
        strategy.cancel("13 days breakout")
        
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-21
      • 1970-01-01
      • 2023-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-14
      • 2022-07-22
      相关资源
      最近更新 更多