# Custom indicators overview

Source: https://tapehawk.com/docs/custom-indicators/overview

> Write your own indicator as a short script — who can, where the editor is, saving and deleting, and how your indicator is drawn and set on a panel.

A custom indicator is one you write yourself, as a short script in TapeHawk's indicator language. TapeHawk's server checks
the script and compiles it; saved, it is kept on your account and appears in the indicator menu of every panel, next to
the indicators TapeHawk ships.

Writing indicators needs a confirmed account — see [Access levels](https://tapehawk.com/docs/getting-started/access-levels).

## Opening the editor

Open the **Indicator** dialog of a panel and choose **Write an indicator…**
at the foot of its left rail — or, on a phone, open the drawer and choose it at the bottom of the indicators. The **My indicators** dialog opens with a
two-line starter script already drawn on the active panel.

![The left rail of the Indicators dialog: the groups, including My indicators, the drawing styles, and Write an indicator… at its foot.](https://tapehawk.com/docs/shots/editor-menu-entry.webp)

Across its top:

* **The first list** opens an indicator you saved. **New indicator…** means the script in the
  dialog is not a saved one.
* **Examples…** loads one of eight starter scripts — see
  [Examples](https://tapehawk.com/docs/custom-indicators/examples). Loading one replaces the script in the dialog.
* **The name box** holds the indicator's name: letters, digits and `_`, up to 40 characters.
* **Delete** appears when the name is one you have saved.

Below them, two tabs show the same script two ways:

* **Blocks** builds a simple indicator from rows of controls, without typing — see
  [Block builder](https://tapehawk.com/docs/custom-indicators/builder).
* **Source** is the script as text — see [Source editor](https://tapehawk.com/docs/custom-indicators/source-editor)
  and the [Language reference](https://tapehawk.com/docs/custom-indicators/language-reference).

Switching tabs changes nothing in the script. While you work, TapeHawk checks the script after each pause in typing and
draws it on the active panel, so you see the result on real data before you save. Closing the dialog takes that preview
off the chart.

![The My indicators dialog open beside a BTCUSDT candles panel: the starter script on the Blocks tab, the check reading Compiles at the foot, and its line drawn over the candles as a preview.](https://tapehawk.com/docs/shots/editor-overview.webp)

## Saving and deleting

**Save** stores the script under the name in the name box, and is switched off while the box is
empty. The server checks the script again; if it refuses, the reasons appear under the script and nothing is stored.

* **Saving under a name you already use** replaces that indicator. Unless it is the one you opened, the dialog asks
  before it overwrites the saved script.
* **Panels drawing the indicator** in this browser tab pick up the new version straight away; other tabs and devices get
  it the next time they load the chart.
* **Delete** asks before it removes the indicator. Panels that had it added keep an entry
  marked as deleted, which you can remove from the indicator menu. When the server does not take the deletion, the line
  at the foot of the dialog says so with its reason, and the indicator stays in the list.

The line at the foot of the dialog confirms what happened. When a save removes or renames a condition or signal that a
rule of yours names, it says so instead: those rules no longer match anything in the script.

## Your indicator on a chart

Saved indicators are listed in the indicator menu under **My indicators**. Add one as you would any
indicator — see [Indicators](https://tapehawk.com/docs/indicators). Which panels offer it depends on its
[clock](https://tapehawk.com/docs/custom-indicators/language-reference#clocks):

* **A bar-clock script** is offered on candles, footprint and heatmap panels.
* **A `@print` or `@book` script** is offered on heatmap panels, which record the trades and the order book it runs on.
  Candles and footprint panels list it by name under **My indicators** with a note saying so.
* **A `@cell` script** is offered on every panel kind, whether it plots a line, only marks, or both.

Once added:

* **Where it is drawn.** When every line the script plots is a price, the indicator is drawn over the price; otherwise it
  is drawn in a band — see [Over the price, and in bands](https://tapehawk.com/docs/indicators#over-the-price-and-in-bands).
* **Its name** on the panel is the name you saved, followed by the values of its number inputs, so two copies with
  different settings can be told apart. A script that declares a `mark` can be on a panel only once, like
  TapeHawk's own indicators that mark events, and leaves **Add** once added.
* **Its settings.** The gear opens the same dialog as for any indicator. The **Parameters** tab has
  a control for each number, switch and list `input` in the script, within the bounds the script declares and the ones
  TapeHawk sets. A control is named as the script names its input, except for a few common names — such as `mode` or
  `step` — which show TapeHawk's own label for that word. A colour input is a colour control, starting at the colour the
  script declares.
* **How it looks.** On a panel, a saved indicator draws with the colours, pens, shifts, fills and horizontal lines its
  script declares, as the editor's preview does. A line whose script names no colour takes one from a fixed set.
* **While the editor has it open**, panels drawing the indicator draw the script in the dialog instead — its current
  draft, at default settings, with its declared colours — until the dialog closes.
* **Its marks.** A `@print` or `@book` script's marks are drawn on the heatmap in the shape and colours it declares, like
  the marks of TapeHawk's own order-flow indicators — see
  [Marks on the heatmap](https://tapehawk.com/docs/indicators#marks-on-the-heatmap). They are computed in your browser: a `@print` script
  from the trades the panel already holds, a `@book` script from the moment it is added, because the order book is not
  recorded — so neither fills the heatmap's recorded history the way TapeHawk's own detectors do. A `@cell` script's
  marks are drawn on candles, footprint and heatmap panels alike, in the same shapes and plates, on each column the
  panel has loaded once the column has closed. On a heatmap panel the columns are the heatmap's own, whose width
  follows the range, so those marks can differ from the bars a rule on the script is checked on. Pointing at a mark
  shows the tooltip on a heatmap panel only; candles and footprint panels have no mark tooltip.

A saved script that no longer compiles cannot be drawn. The menu lists it by name under
**My indicators** with This indicator's script no longer compiles, so it cannot be drawn. Open the editor to fix it.

## Alerts

An indicator you write can alert you through its marks, the same way the built-in signal indicators do — and a candle
script, which cannot declare a `mark`, through its `alert` conditions.

* **On the candle clock, an `alert` is a condition you can be alerted on.** It is judged at the close of each candle, and a
  rule on it fires on the close where the condition turns true. The script appears in the alert form under
  **My indicators**, where you tick its conditions and pick the
  **Timeframe** they are judged on; from a panel's settings it watches that panel's candles. A
  script reading another market (`refclose`) can only be alerted on a symbol whose base asset can be read off its name —
  one quoted in KRW, USDT, USDC, FDUSD, BUSD or USD.
* **On any other clock an `alert` line is refused.** The check and the save both reject it, naming its line. On the trade
  or footprint-column clock the message suggests turning it into a `mark`; on the order-book clock, whose signals cannot
  carry an alert yet, it says the script can only draw there — see
  [`alert`](https://tapehawk.com/docs/custom-indicators/language-reference#alert).
* **A `mark` with a `cap`** appears in the alert form under **My indicators**, unless the script runs on
  the order book. A rule on it notifies you each time the mark is made, at most as often as its `cap` allows, and counts
  towards your rules — see [Signal alerts](https://tapehawk.com/docs/alerts/signal-alerts#your-own-indicators). A mark without a `cap`
  cannot be chosen.

## Where to go next

* [Block builder](https://tapehawk.com/docs/custom-indicators/builder) — make a moving average and a line without writing code.
* [Source editor](https://tapehawk.com/docs/custom-indicators/source-editor) — the check, the error list and the preview.
* [Language reference](https://tapehawk.com/docs/custom-indicators/language-reference) — everything a script can say.
* [Examples](https://tapehawk.com/docs/custom-indicators/examples) — the eight starter scripts, explained.
* [Limits and troubleshooting](https://tapehawk.com/docs/custom-indicators/limits-and-troubleshooting) — what TapeHawk refuses, and why a
  script draws nothing.
