【问题标题】:Take Profit 1 and Stop loss + Moving Stop loss获利 1 和止损 + 移动止损
【发布时间】:2022-11-26 12:11:20
【问题描述】:

任何人都可以在这段代码中帮助我,因为我被卡住了。 我成功地进行了买入和卖出条目,但我无法对止盈和止损进行编码。 条件如下:

  1. TP1 在“ATR 止损查找器”指标的高位关闭 50% 的入场交易,从 ATR 的高位入口栏的前一根蜡烛
  2. 在 ATR 的低值处止损入口栏的前一根蜡烛

    如果 TP1 达到:

    1. 将 SL 移至入门级别

      如果达到 TP1 的两倍,则再次将 SL 从入口水平移动到 TP1 和入口之间的一半长度,依此类推,如下所示
      如果达到 TP1 的三倍,则再次将 SL 从先前水平移动到双 TP1 和入场点之间的一半长度,依此类推,如下所示

      先谢谢了

      enter image description here

      enter image description here

      Buy = direction<0 and buySignal
      plotshape(Buy, style = shape.triangleup, location=location.belowbar, size=size.small, color = color.green)
      
      Sell = direction>0 and sellSignal
      plotshape(Sell, style = shape.triangledown, location=location.abovebar, size=size.small, color = color.red)
      
      longCondition = Buy
      if (longCondition)
          strategy.entry("My Long Entry Id", strategy.long)
      
      
      shortCondition = Sell
      if (shortCondition)
      strategy.entry("My Short Entry Id", strategy.short)
      

【问题讨论】:

  • 我不明白“TP1 在“ATR 止损查找器”指标的高点关闭了 50% 的入场交易,来自入场柱的前一个蜡烛的 ATR 的高值”。您的入场交易似乎是按市场价格进行的,但是 ATR SL Finder 的最高价是如何计算的? “来自高价值……”是什么意思?
  • 我添加了2张图片,请查看

标签: pine-script


【解决方案1】:

当您声明进场时,您也可以这样声明您的止损:

if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)
    
    StopLoss = x2 // x2 is the value of the ATR SL Finder indicator for the green line
    strategy.exit(id='Exit', from_entry="My Long Entry Id", stop=StopLoss)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-26
    • 2022-06-17
    • 2021-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    • 2022-12-04
    相关资源
    最近更新 更多