Learn
Limits and honest notes
What a script can and cannot do in this release, said plainly.
Private, in your browser
Scripts are private to your account and, in this release, run in your browser only. Sharing is not available.
What is not switched on
Script alerts on your own scripts are not switched on for members in this release. No script can place real orders: there is no live trading and no broker connection. The full list is in the wiki: What is not available yet.
The Strategy Lab
Members can test a strategy in the chart's Strategy Lab. On the free chart plan it has 10 runs a month on up to 92 days of history. It runs a strategy over history and reports its trades. See Testing in the Strategy Lab.
Traps in the editor
When you type a script by hand, the editor does not indent the line after the header for you. The header lines such as edition and display must be indented by four spaces; without them the editor reports E3102 and its suggested fix does not help. Pasting a sample avoids this.
The chart's legend and the list of your scripts show the script name from the name field at the top of the editor, not the name in the header line. A new script is called My indicator until you type a name there and press Save.
Results can be wrong
A script computes what its code says, on the data the chart has. That can differ from what you meant. Nothing a script draws is financial advice.
Editions
Write edition = 1 in the header of every script. It names the edition of the language the script is written for, so that a later edition can change the language without changing what an old script means.
Replay and time
Cuprel is designed for deterministic replay: the same data and the same settings are meant to give the same results when a run is repeated. A script reads the time of the bar, not the time of the machine. A mark that depends on later bars, such as a swing pivot, is known only after those bars have closed. More on replay.
Source conversion
The editor has an experimental source conversion for a limited subset of scripts written for other platforms. Only a small tested subset converts; anything else is refused with a reason, and a refused script is not saved. See Import.
Limits of a run
Every run is bounded. A script that reaches a limit stops with a code, the bar and the line; nothing is dropped silently. These are design limits of the engine at production@9a82bf9, not measurements of speed.
| Limit | Value | At the limit |
|---|---|---|
| History depth, default | 2,048 bars | Series start at this depth and grow as the script needs. |
| History depth, cap | 8,192 bars | A read past the cap stops the run, or the compile when the number is written in the script. |
| Steps per bar | 500,000 | The run stops on that bar with a named error. Code E-LIMIT-OPS. |
| Wall clock of an indicator run | 5 seconds | A watchdog stops the run. Code E-LIMIT-TIME. |
| Logical memory held | 128 MiB | Counted in logical bytes, not host memory. The run stops with a named error. |
| Elements in a collection | 100,000 | An array, map or matrix larger than this stops the run. Code E-LIMIT-ITEMS. |
| Length of a text | 1,000,000 | In characters. Code E-LIMIT-TEXT. |
| Call depth | 64 | Functions called inside one another. Code E-LIMIT-DEPTH. |
| Source size | 400,000 | In characters. Code E1090. |
| Line length | 20,000 | In characters. Code E1092. |
All limits are on Resources; every code is in the error index. In the wiki: Limits and budgets and The editor.
Next: the seventeenth lesson of the course in the MillionChart wiki, Staying inside the limits. The whole course: Write your own scripts.