0

如何输入交易策略,以便准确分别记录“进多/出多”和“进空/出空”头寸?

// LONG
    strategy.order("LONG", strategy.long, when = window() and buy)  // buy long when "within window of time" AND crossover
    strategy.order("SHORT", strategy.short, when = window() and sell)               // sell long when "within window of time" AND crossunder  

// SHORT
    strategy.order("SHORT", strategy.short, when = window() and sell and shouldTrade)  // buy long when "within window of time" AND crossover
    strategy.order("LONG",  strategy.long, when = window() and buy and shouldTrade)    

在此处输入图像描述 但正如你在图片中看到的,它只显示“ENTER LONG / EXIT LONG”,它完全忽略了从“Enter SHORT / EXIT SHORT”获得的利润,它甚至没有显示。

4

2 回答 2

0

自从你的问题出现以来已经有一段时间了。我有两个建议:

  1. 也许它是后端的东西,现在工作正常?我已经测试过类似的东西,它只是工作

  2. 根据评论,//LONG 部分的空头订单似乎是为了平仓,而不是平仓多头并开空头。同样,我理解 //SHORT 一侧的多头订单是为了平仓空头头寸,而不是平仓和恢复未平仓头寸。如果这是正确的,您可以尝试组合使用strategy.entry()andstrategy.close()而不是stratagy.order().

于 2020-02-01T22:03:26.593 回答
0

如果我正确理解您的问题,您想要的是or的comment属性。无论您放置在那里的任何文本都会显示在订单日志中,以便您区分不同的条目。strategy.orderstrategy.entry

Pine 脚本参考 - strategy.order

于 2018-11-09T20:02:22.287 回答