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:
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:
script "Delta histogram"names the script; the name appears in the legend.inputdeclares a setting you can change in the script settings.data chart = subscribe(data.ohlcv)subscribes to the chart’s own bars.paneandplotdeclare where the output goes and how it looks.on chart.closeruns 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.
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:
| Value | Type | Meaning |
|---|---|---|
context.exchange | string | Venue id: "binance", "binancef", "bybitf", "okxf", "hyperliquid", "asterf", "lighterf", or "aggregate". |
context.symbol | string | The instrument symbol. |
context.base | string | Base asset, for example "BTC". |
context.quote | string | Quote asset, for example "USDT". |
context.timeframe | timeframe | The chart timeframe. |
context.tickSize | float | Minimum price increment. |
context.stepSize | float | Minimum 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:
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.