Pinescript 交易在获胜后暂停 xx 小时
Pinescript trade pause xx hours after wins
我想应用一个函数在交易获胜后将策略暂停 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)
我想应用一个函数在交易获胜后将策略暂停 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)