'Order's limit (9000) was reached' のエラーが表示されます

このエラーは、注文発注や取引決済の回数がストラテジーで許容されている最大の回数に達したことを示しています。この制限はプランにより異なっており、弊社サーバーの効率的な稼働を目的として定められているものです。

このエラーの回避策として、"strategy()" 関数のパラメーターに "trim_orders" を使用する方法があります。このパラメーターを "true" に設定すると、新規注文が「トレード一覧」に表示されると同時に、注文数の制限を超えた注文が古いものから順に削除されます。

 

こちらはその一例です:

//@version=5
strategy("My strategy", overlay = true, margin_long = 100, margin_short = 100, trim_orders = true)

if bar_index % 2 == 0
    strategy.entry("My Long Entry Id", strategy.long)

if bar_index % 2 != 0
    strategy.entry("My Short Entry Id", strategy.short)

または、注文条件に時間範囲の確認を入れることによって、ストラテジーが注文を発注する期間を制限することもできます。下記スクリプトの例では、現在のバーの時刻が2つのタイムスタンプの間にあるかどうかをチェックすることによって注文発注の時間範囲を設定しています。

//@version=5
strategy("My strategy", overlay = true, margin_long = 100, margin_short = 100)

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)