我看到“已达到最大订单数量(9000)。”错误

此错误意味着策略下达的订单或平仓的交易数量超出了允许的最大数量。这些限制因方案而异,可使我们的服务器更高效地运行。 

为避免此错误,请将您的策略转换为Pine脚本v6。在v6中,所有超过限制的订单都会被削减:每个新订单都会出现在交易列表中,并且超过订单限制的最早订单将被删除。

或者,您可以通过检查订单条件中的时间周期来限制策略下订单的日期。以下示例脚本通过检查当前K线的时间是否在两个时间戳之间来建立下订单的时间周期。

//@version=6
strategy("My strategy", overlay = true)

enableFilter = input(true,  "Enable Backtesting Range Filtering")
fromDate     = input.time(timestamp("20 Jul 2023 00:00 +0300"), "Start Date")
toDate       = input.time(timestamp("20 Jul 2099 00:00 +0300"), "End Date")

tradeDateIsAllowed = not enableFilter or (time >= fromDate and time <= toDate)

longCondition =  ta.crossover(ta.sma(close, 14),  ta.sma(close, 28))
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))

if longCondition and tradeDateIsAllowed
    strategy.entry("Long", strategy.long)

if shortCondition and tradeDateIsAllowed
    strategy.entry("Short", strategy.short)
HTML