Pinescript交易暂停xx小时后获胜



我想应用一个函数在赢了交易后暂停策略xx小时或酒吧,怎么做?因为我的策略是趋势,所以在大的变动之后总会有一段我想要避免的垃圾时间,例如,在赢了(正确的趋势)交易后暂停24小时。谢谢你。

您可能会发现这个例子适合:

https://www.pinecoders.com/faq_and_code/how-can-i-implement-a-time-delay-between-orders

或者这个例子:

X秒后重新开仓

//@version=5
strategy("strategy.closedtrades.exit_time Example 2")
// Strategy calls to emulate a single long trade at the first bar.
if bar_index == 0
strategy.entry("Long", strategy.long)
reopenPositionAfter(timeSec) =>
if strategy.closedtrades > 0
if time - strategy.closedtrades.exit_time(strategy.closedtrades - 1) >= timeSec * 1000
strategy.entry("Long", strategy.long)
// Reopen last closed position after 120 sec.                
reopenPositionAfter(120)
if ta.change(strategy.opentrades)
strategy.exit("Long", stop = low * 0.9, profit = high * 2.5)

最新更新