FlowscopeDocs

Flowscope Script

The typed language for writing your own indicators and strategies inside the Flowscope terminal.

Flowscope Script is the language for your own indicators and strategies in the terminal. A script states up front which market data it needs, which settings it exposes and what it draws, then reacts to events as the data arrives. Strategies add a TradingView-style broker emulator and the Strategy Tester.

The same script runs over the chart’s loaded history and keeps going as new bars arrive. You never write a separate code path for the live edge.

What you can build

  • Indicators that draw lines, histograms, candles, markers and fills on the price pane or in their own panes.
  • Order-flow studies from volume delta, CVD, open interest, liquidations, funding and individual trades, on one venue or an aggregated market.
  • Strategies that place simulated orders, backtest over the chart’s history and report in the Strategy Tester.
  • Alerts with typed payloads that fire on live data.

Write scripts in the script editor (Script editor in the bottom bar) and put them on the active chart with Add to chart.

A first script

This script plots volume delta as a histogram coloured by sign, with a smoothed line over it:

delta-histogram.fs
script "Delta histogram"

input smoothing = input.int(9, title: "Smoothing", min: 1, max: 50)

data chart = subscribe(data.ohlcv)

pane deltaPane = pane(title: "Delta", height: 0.25)

plot (
  bars = plot.histogram(title: "Delta", on: deltaPane)
  trend = plot.line(title: "Smoothed", color: color.amber, width: 2, on: deltaPane)
)

on chart.close {
  let delta = chart.delta()
  let shade = (delta ?? 0.0) >= 0.0 ? color.up : color.down
  bars.plot(delta, color: shade)
  trend.plot(ta.ema(delta, smoothing))
}

Read it from top to bottom:

  1. script "Delta histogram" names the script; the name appears in the legend.
  2. input declares a setting you can change in the script settings.
  3. data chart = subscribe(data.ohlcv) subscribes to the chart’s own bars.
  4. pane and plot declare where the output goes and how it looks.
  5. on chart.close runs once for every confirmed bar and feeds both plots.

chart.delta() returns null when a bar has no volume split. The histogram shows a gap for that bar and ta.ema carries on with the next value. Missing data is always explicit; see missing values.

Tip

Put the script on an aggregated market, such as BTC on all venues. The delta then covers every venue at once.

Chart context

A script runs on a chart. The context values describe it and stay fixed for a run:

ValueTypeMeaning
context.exchangestringVenue id: "binance", "binancef", "bybitf", "okxf", "hyperliquid", "asterf", "lighterf", or "aggregate".
context.symbolstringThe instrument symbol.
context.basestringBase asset, for example "BTC".
context.quotestringQuote asset, for example "USDT".
context.timeframetimeframeThe chart timeframe.
context.tickSizefloatMinimum price increment.
context.stepSizefloatMinimum quantity increment (0.0 when unknown).

Changing the chart’s market or interval re-runs the script with the new values. context is readable anywhere, including setup and state initialisers. It is handy for distances in ticks:

Flowscope Script
script "Distance from the average in ticks"

input len = input.int(50, title: "Average length", min: 2, max: 500)

data chart = subscribe(data.ohlcv)

pane ticksPane = pane(title: "Ticks from SMA", height: 0.2)

plot ticks = plot.histogram(title: "Ticks", on: ticksPane)

on chart.close {
  let c = chart.close
  let avg = ta.sma(chart.close, len)
  if c != null && avg != null {
    let away = (c - avg) / context.tickSize
    ticks.plot(away, color: away >= 0.0 ? color.teal : color.purple)
  }
}

Timeframes cannot be multiplied directly; convert with time.tfSeconds, compute in seconds and convert back with time.tfFromSeconds. See multiple timeframes.

Where to go next