【发布时间】:2021-04-18 17:55:38
【问题描述】:
我在 Pine Editor/TradingView 中编写了这个买入/卖出策略:
buy_condition= a<b
sell_condition= a>b
strategy.entry("Long", strategy.long, when=buy_condition)
strategy.exit("L_Out", "Long", profit=1000, loss=500)
strategy.entry("Short", strategy.short, when=sell_condition)
strategy.exit("S_Out", "Short", profit=1000, loss=500)
在多头或空头头寸中,当相反的条件成立时,它会改变头寸,但我希望它保持在头寸,直到它达到盈利或止损。然后它可以再次进入任何适合的位置。我该如何编写这条规则?
【问题讨论】:
-
嗨 Onur Kiris,欢迎来到 Stack Overflow。请提供minimal reproducible example 以帮助我们重现您的问题。
标签: python algorithmic-trading