CoinScriptCoinScript

CoinScript

Write your own indicators, signals and alert conditions in CoinScript, test them in the backtest and put them on the chart like any other indicator.

CoinScript is the terminal's scripting language for custom indicators. You write JavaScript with a fixed library: candles, volume, order flow, liquidations, open interest, funding and, for stocks, revenue, earnings and P/E are ready to use as data series. With feed() a script reads further series from the terminal, such as on-chain values, yields or COT, and with symbol() the candles of other symbols. On top of that come moving averages, RSI, crossovers and drawing functions. A script can put lines on the price chart, fill its own pane below the chart, place signals as triangles on the candles and provide conditions for alerts.

CoinScript
// CoinScript · EMA band on the price
const fast = ema(close, input('Schnell', 21))
const slow = ema(close, input('Langsam', 55))
plot(fast, { title: 'EMA 21', color: '#00FFDA', overlay: true })
plot(slow, { title: 'EMA 55', color: '#FF1919', overlay: true })
signal(cross(fast, slow), { title: 'Kreuzung', color: '#FFEB3B', pos: 'below' })

A script does not run candle by candle, but once over all the chart's candles. Each data series is a list with one value per candle, oldest first. Exactly how this works is explained under Language.

Open the MantaAi panel

  • Top bar → MantaAi. If the bar is too narrow, you can find MantaAi under More.
  • Indicators (/) → Script (“Write your own indicator”).
  • Super search (CtrlK, Mac: CmdK) → “Open code editor (custom indicators)”.

On the desktop, the panel opens to the right of the chart. You can make it wider or narrower by dragging its left edge, and the terminal remembers the width. If you close it, the code, console, backtest and chat are kept as long as the page stays open.

At the top of the panel are Templates, New and four tabs. The panel opens on the MantaAi tab if your plan includes MantaAi, otherwise on the Editor tab.

TabPurpose
MantaAiThe terminal’s assistant writes CoinScript for you and answers questions about the chart (Plus and up), see MantaAi
EditorWrite code, run it and put it on the chart
BacktestTest the script's signals as a strategy, see Backtest
My scriptsYour saved scripts

Templates

Templates loads a ready-made script into the editor. It replaces the current code and starts a new script.

TemplateWhat it shows
Delta EMASmooths the volume delta with an EMA and shows it as a histogram.
CVD divergenceMarks candles where price and CVD diverge, and draws the CVD as a pane.
Funding extremeNormalizes the funding rate as a z-score; values above 2 or below −2 count as extreme.
EMA bandTwo EMAs directly on the price chart, crossovers as yellow markers.
Revenue vs. priceFor stocks: revenue and earnings on their own scale; marks reports where revenue rose and the price has fallen since the last report.
EmptyAn empty script with a quick reference in the comments.

New starts a new script named “My indicator” with the Empty template and clears the console.

You can find all templates with explanations under Examples.

The editor

At the top you enter the script name, up to 60 characters. It later appears in the legend and in the indicators list.

The editor helps you write:

  • Suggestions: As you type, it suggests CoinScript's data series and functions, with their syntax and a short explanation.
  • Explanation on hover: If you move the mouse over a name such as ema or funding, it shows what is behind it.
  • See errors immediately: It underlines anything forbidden or misspelled in red, and you see the message on hover.
  • Tab indents by two spaces, and it closes brackets and quotation marks by itself.

Below it are two buttons:

ButtonKeyboard shortcutWhat happens
RunCtrlEnter (Mac: CmdEnter)Calculates the script on the chart's candles and writes the result to the console. Nothing changes on the chart.
Add to chartCtrlShiftEnter (Mac: CmdShiftEnter)Saves the script as a custom indicator and puts it on the chart. If the script is already saved, the button is called Update on chart.

The console

Below the editor is the console, with the Console and Reference tabs. To the right of them is the cursor position, for example “Line 3, column 12”.

After Run, the console shows a summary, for example:

Text
Kompiliert in 1,2 ms · 2 Plots · 1 Signal (14 Treffer) · Schnell = 21, Langsam = 55
  • Successful runs appear in the color for rising prices (turquoise by default).
  • Errors appear in red, for example “Error in line 1, column 6: ‘nope’ is not defined”. Clicking the row puts the cursor at that spot in the code.
  • Notes about missing data appear in yellow, for example “No data for oi, funding on SPY: the values stay empty.”
  • Your own output with console.log() appears in gray, console.warn() in yellow and console.error() in red.

A script must call plot(), signal() or alertcondition() at least once, otherwise the console reports “No plot(), signal() or alertcondition() found”. The Reference tab lists all functions and data series at a glance.

Scripts on the chart

After Add to chart, the script appears on the chart like any other indicator:

  • plot() with overlay: true draws lines on the price chart, all other plots go to their own pane below the chart.
  • signal() places triangles below the candle (pos: 'below') or above it (pos: 'above').
  • The legend shows the script with its name and the values under the crosshair.
  • The gear in the legend or in the pane header opens the script's settings, and so does double-clicking its row in the legend or its pane. Inputs lists all the numbers you made adjustable with input(); if you change them, the script recalculates immediately. Under Style you set the color and line width of its lines, histograms and signals.
  • The AI icon to the right of the gear opens the script in the MantaAi panel, on the MantaAi tab and with the script in the editor. See MantaAi.

The script recalculates with every new candle and with price moves of the running candle, at most every 300 milliseconds. If the chart loads older candles as you scroll back, it calculates over those too. In replay it sees only the candles up to the replay point.

If a script draws nothing, its pane or the price chart says why at the bottom left, for example “Script error: … (line 3)” or that data is missing.

You can also find your scripts under Indicators (/) → Custom. There you add them with + Add like any indicator and can publish them, see Sharing scripts.

My scripts

The My scripts tab lists all your scripts. Below the name it says where the script draws and what it provides, for example “Pane · 1 plot · 2 signals” or “On the price chart · 2 plots”. Each row has:

  • a toggle that puts the script on the chart or takes it off,
  • the bell (“Alert on this script”) for a script alert (Plus and up), see Script alerts,
  • Edit, which loads the code into the editor,
  • Delete, with Undo in the popup. A deleted script also disappears from the chart.

Where your scripts are saved

  • When you are signed out, the terminal saves your scripts in this browser. The list then says “Saved in this browser. When you are signed in, your scripts are stored in your account.”
  • When you are signed in, they are stored in your account and available on all devices. Scripts you created in this browser while signed out are uploaded to your account when you sign in.

The browser remembers what is currently in the editor even without saving, until you secure it with Add to chart.

Limits

LimitValue
Length of a script for saving20,000 characters
Calculation time per run on the chart and with Run250 ms
Calculation time for a backtest2 seconds
plot() / signal() / hline() / alertcondition() / input() per script24 / 24 / 32 / 16 / 16
Size of a single array5,000,000 values

If a script exceeds the calculation time, the terminal stops it with “Script aborted: time limit exceeded”. The chart stays usable, because scripts run isolated from the rest of the terminal. On the chart, the terminal tries a stopped script again after 10 seconds.

A script cannot load anything from the internet, read or store data in the browser, or change anything outside its own calculation. It sees only the data series CoinScript gives it.