Black Friday 30% off Basic and ProBlack Friday −30%Ends in––d––h––m––sSee the deal

The editor

Where indicators are written, tested and saved.

The commands

Next to the name are the script commands, in the order you use them; full screen is at the top. There is no separate Compile: Save and Add to chart do it, after saving.

CommandWhat it does
Save ⌘ SAlways saves, even with errors. Then it compiles and writes the result in the console. The dot on the icon means there are unsaved changes. On systems other than Mac the shortcut is Ctrl S.
Add to chartSaves and compiles. Without errors it adds the indicator to the active chart, or updates the one already there; with an error the chart doesn’t change.
Full screenThe editor covers the charts, to give you room. The same button puts it back.

Every save that compiles updates the copies of the indicator already on charts, with their settings. If you removed an option from an input.choice, anyone who had chosen it goes back to the default.

The arrow at the end of the name row opens the script menu: New indicator, Make a copy, Delete…, Publish to TotalTrade…, this Documentation and, below, your saved indicators, to open with one click. Before you lose unsaved changes, the editor asks.

Suggestions as you type

Animation: the suggestions after ta. and the signature
After ta. the functions appear; when you open the parenthesis, the arguments.
  • As you type, the script’s names, the language keywords and the allowed Python functions appear. After a dot, the members of ta, math, format, draw, input, plot, request, the candles, price levels, news, lists, dictionaries and your classes. A news item is recognised in for event in news, also with enumerate and in comprehensions, and in news[i].
  • Enter or Tab accept, Ctrl Space opens them, Esc closes them.
  • When you open a function’s parenthesis its signature appears, with the argument you’ve reached highlighted.
Animation: the explanation of a function on hover
Hovering over a name shows its signature and what it does.

Errors

Animation: a syntax error underlined and then in the console
Syntax errors show up right away; the others on save, with the line.
  • Syntax errors, like an unclosed parenthesis, are underlined as you type, with a mark next to the line number. Hover over it to read the message.
  • On save the compiler checks everything else: the error goes to the console, with the line, and stays marked on the line until the next edit.
  • Errors during the calculation, like a division by zero, appear in the Log tab, with the line. The indicator’s legend only says “Script error”. See Errors and recalculation.

The console

Below the script there are two tabs. To raise them drag the top edge: an error raises them by itself.

The console with a compile error
Messages: every save adds a line, with the time.
  • Messages is the editor’s log: every save or publication adds a line with the time, and the error with its line. It keeps the last 100; right-click for “Clear messages”.
  • Log shows the print output and the errors of the last calculation of each indicator, on all charts. Each calculation redoes everything, so the lines are replaced instead of repeating.
Animation: print output in the Log tab
print writes to Log, with the calculation time and the code line.

Reading the built-ins’ code

In the Indicators dialog, a card’s </> button opens the code in the editor as an unsaved copy, “Name (copy)”. “Source code” and “Copy code” in the legend’s More menu do the same. If you save it, it becomes one of your indicators.

Animation: a built-in’s code opened in the editor
A built-in’s code, opened as a copy to edit.

Where scripts end up

Saved and without errors, a script is in the catalog, under My indicators. With an error it stays in the editor menu, but leaves the catalog until you fix it. To share it, see Publishing.