The script editor
Write, save, open and organise your scripts, and put them on a chart, in the editor panel on the right.
The script editor is a panel at the right of the terminal. Script editor in the bottom bar shows and hides it; drag its left edge to make it wider or narrower.
The toolbar
| Part | What it does |
|---|---|
| Script name ▾ | The script menu: save, copy, rename, create, the scripts you used lately, open, delete. A dot after the name means unsaved changes |
| ▷ Add to chart | Saves and puts the script on the active chart. Opened from a chart’s legend it reads Update on chart and replaces the code there. Disabled while the code has errors |
| Save | Saves to your scripts (Ctrl+S); someone else’s script is saved as your own copy |
| Share | Share the script with a link or with people (signed in) |
| ⋯ | Open a script, show or hide the minimap and the log, the font size |
In a narrow panel Add to chart shows only its ▷ icon and the minimap steps aside; long lines scroll sideways instead of being cut off.
The script menu
| Item | |
|---|---|
| Save script | Ctrl+S |
| Make a copy | A copy named “… (copy)”, opened in the editor |
| Rename… | Changes the name in the script’s script "Name" line |
| Create new | An indicator or a strategy from a template, or a script from a share link |
| Recently used | The last five scripts you opened |
| Open script… | All your scripts (Ctrl+O in the editor) |
| Delete script | Asks once more: click again within three seconds. Scripts others shared with you are removed from your list instead |
Open script
Open script… lists every script you have, with a search field and filters for indicators, strategies, scripts shared with you and scripts added from the library. Click a script to open it. Hover a row for its buttons: + puts the script on the active chart, the bin deletes it (a second click confirms) without opening it first.
Your scripts in the indicators dialog
The indicators dialog (Indicators in the top bar, or /) has My scripts under Personal. Click a script there to add it to the chart; { } opens it in the editor. Scripts already on the chart are marked On chart, and New script starts a new indicator in the editor.
Writing code
| Keys | |
|---|---|
| Ctrl+S | Save (and update the chart the script came from) |
| Ctrl+O | Open script… |
| Ctrl+/ | Comment the selected lines out, or back in |
| Enter | New line with the indentation of the last, one level deeper after {, ( or [ |
The code compiles a quarter of a second after you stop typing. Problems appear in a
list under the code with their line and column; click one to jump there. The status
line counts errors and warnings and shows the cursor’s position; Logs opens what
the script on the chart wrote with log.info(...).