【问题标题】:Pyramiding trades with independent take profit (Pinescript)具有独立止盈的金字塔式交易 (Pinescript)
【发布时间】:2021-10-22 06:07:49
【问题描述】:
  1. 假设我有 1 个长信号。止盈设置为 10%(尚未达到)。
  2. 然后,我有另一个长信号(相同的条件)。我想像另一个一样设置 10% 的止盈。
  3. 我希望每笔交易都有独立的止盈,因为入场不是在同一时间。

当我使用金字塔 = 2 时,它将平均两次交易并在平均价格上涨 10% 时同时关闭所有交易。但我想保持获利独立,并在每个人都达到自己的获利时关闭每笔交易。

我的代码:

longProfitPerc = input(title="Long Take Profit (%)",
     minval=0.0, step=0.1, defval=10) * 0.01

longExitPrice  = strategy.position_avg_price * (1 + longProfitPerc)
strategy.entry(id="Long", long = true, when = enterLong())
strategy.exit(id="Long", limit=longExitPrice)

【问题讨论】:

    标签: pine-script algorithmic-trading trading back-testing


    【解决方案1】:

    你在这里:

    longProfitPerc = input(title="Long Take Profit (%)",
         minval=0.0, step=0.1, defval=10) * 0.01
    
    percent2points(percent) =>
        strategy.position_size !=0 ? strategy.position_avg_price * percent / 100 / syminfo.mintick : na
    
    strategy.entry(id="Long", long = true, when = enterLong())
    strategy.exit(id="Long", profit=percent2points(longProfitPerc))
    

    【讨论】:

      猜你喜欢
      • 2020-10-04
      • 1970-01-01
      • 1970-01-01
      • 2016-10-02
      • 1970-01-01
      • 2013-07-25
      • 1970-01-01
      • 2022-08-05
      • 1970-01-01
      相关资源
      最近更新 更多