Docs·TapeScript

Introduction

TapeScript is a scripting language for the tick heatmap in the Tape Delta desktop app. Scripts react to trades, book changes and single orders, draw on the heatmap and play alerts.

TapeScript is a scripting language for the tick heatmap. A script runs on every trade, every order-book change and every move of the best bid and ask. On market-by-order venues it also sees every single order: placed, changed, filled or pulled, and iceberg refills. It can start from stored history, draw lines, markers, shaded zones and price levels on the heatmap, plot a pane under it, and play sound or voice alerts.

TapeScript editor docked beside a live tick heatmap — an absorption script marking prints on the BTCUSDT order book

The TapeScript widget next to a tick heatmap.

TapeScript and Delta DSL

Delta DSL ScriptTapeScript
ChartCandle chartTick heatmap
InputOHLCV of the visible barsTrades, order-book levels, best bid/ask, single orders, a timer
RunsOn each redrawOn each market event
StoredIn your accountAs .tape files on your computer
Available inWeb and desktopDesktop app

Script structure

A script has two parts:

  • Top-level code. Runs once when the script starts. Declare state here: counters, rolling windows, lines to draw.
  • Callbacks. Functions with reserved names that TapeScript calls on market events: onTrade, onDepth, onBbo, onInterval, and on market-by-order venues onOrder and onIceberg.

Inside a callback you update state, add points to lines, place markers, shade zones and fire alerts. With // @history the script first runs over the stored data of a recent period.

If a script has an error, it stops and the Console shows the message and the line number. Other scripts and the chart keep running.

Example

JavaScript
// @name     Big Prints
// @input    mult: float = 6 "Size vs average (x)"

const avg = rolling(200)

function onTrade(price, size, side, time) {
  const ready = avg.full
  const mean = avg.mean
  avg.add(size)
  if (ready && size >= mean * input.mult) {
    marker(time, price, round(size), side === SELL ? "#F6465D" : "#0ECB81")
  }
}

The script keeps the size of the last 200 trades. A trade at least mult times the average gets a marker: red for a sell aggressor, green for a buy aggressor. mult can be changed in the Inputs tab.

Pages in this section

  1. Getting started
  2. Language
  3. Events
  4. Inputs & directives
  5. Built-ins
  6. Drawing
  7. Alerts, sound & voice
  8. Release as an indicator
  9. Sample scripts
  10. Limits & safety