Reference
Reference: limits
Bounds#
| Bound | Value | Beyond |
|---|---|---|
| Script length | 200,000 characters | E950 |
Syntax nesting (parentheses, blocks, else if, operator chains) | 200 levels | E117 |
| Operations per bar (body) and per event (each handler and pattern) | 200,000 by default; budget: from 1 to 20,000,000 | E902 |
Loop iterations (for over a range, while) | 10,000 | E906 |
| Nested function calls | 65 | E914 |
| List or map size | 1,000,000 elements | E941 |
ring(n) | n from 1 to 1,000,000 | E940 |
norm.* populations (by: keys, all calls of a script together) | 200,000 | E933 |
norm.* window in values | 1,000,000 | clamped |
Objects (line.new, box.new, label.new) | 500 per script | the oldest are deleted |
| Tables | 20 live tables; 1 to 50 columns and rows | E928 on the size |
print | last 500 bars, 500 characters per line | ignored |
mbo.levels(side, n) | n from 1 to 500 | clamped |
mbo.large(min) | 500 results | truncated |
book.depth, book.imbalance | 300 levels | clamped |
of.vpin(…, buckets:) | 1 to 1,000 | clamped |
level_history: | default 2 minutes, at most 30 minutes | E942; longer mbo.level window: E933 |
flow_history: | default 5 minutes, at most 60 minutes | E942; longer of.* window: E933 |
mbo_history: (indicators) | default 30 minutes | — |
book_history: (indicators) | default 2 hours | — |
mbo_max: | default 25,000,000, from 1,000 to 100,000,000 order-by-order events per open bar | E942 / E944 |
| Book snapshots held for one open bar | 8 hours | E944 |
initial_balance: | 1 to 390 whole minutes | E942 |
| Bars received by an indicator | the chart's last 2,000 bars | — |
| Bars received by a strategy or research script on a chart | at launch the last 4,000 to 8,000 bars (all if fewer), then grows up to 48,000; beyond, the start moves by 8,000. With the footprint: the last 2,000 | — |
| Bars per script | 50,000 | E945 |
persist memory | 256 KB, 50,000 values, 16 levels of nesting; 500 memories per mode | not written (the previous memory is kept) |
| Live order-by-order recording | 8 instruments | — |
request(…, symbol:) | 8 symbols | — |
Strategies and research#
| Bound | Value |
|---|---|
| Positions | one at a time (a pending entry counts) |
| Equity curve | 300 points |
| Trade list in the Report | latest 200 trades |
| CSV export | 200,000 trades |
Bootstrap draws (ci:) | 0 to 20,000 (default 1,000; 400 in sweeps) |
| Sweep | 40 values; time limit 30 s to 60 min (60 s for strategies computed at once) |
| Long backtest | 600 days; 20,000 bars per day; 15,000,000 order-by-order events per day's window; one at a time; default time limit 120 minutes |
Performance and memory#
- The engine counts operations instead of time, so a script behaves the same on a fast and on a slow machine. If you reach the budget, look first for loops over large collections run on every event.
- A collection operation (sum, sort, keys, percentile…) costs about
1 + n/8operations. mbo.large(min)costs about one operation per 64 resting orders.mbo.level(…)totals are cheap;depletions,replenishments,refill_*andtime_at_bestscan the window once per call, on first read.level_history:keeps every event of every price for its duration. On a very active market a long history uses a lot of memory: keep it as short as your windows allow.- Strategies and research scripts with a fixed order-by-order start read data as a stream: memory stays roughly constant whatever the length of the run.
Not supported#
- Real orders. Strategies are always simulated.
- Several positions at once, pyramiding, direct reversal, trailing stops (
trail:does not exist; manage a stop withexit()from your own logic). - Dates as values (
2025-01-02) and ranges outsidefor. - Generic
set<…>,heap<…>,deque<…>,series<…>;window<T>(…)(writewindow(d)). - Imports of more than one level, and
importof anything other thanstrate/patterns/<file>andmy/<name>. - Unicode escapes in strings (
\u{41}stays as written). persistin strategies and research scripts.- Book snapshots, footprints,
request(…, symbol:)and drawings in long backtests. request(…, symbol:)in the built-in check (it has no other instrument: E936).- Reading the future: negative history indexes, the footprint of a bar inside a handler, and any data after the Replay cursor.
- Header keys and named arguments that are not documented are ignored, not rejected.