XFlow Script
The indicator language of XFlow Charts. One document, complete enough to write a working indicator from, on candles, the footprint, the tape, quotes, depth of book, individual orders, options gamma and what the chart's own indicators draw.
Updated 2026-10-12
What XFlow Script is
XFlow Script is the small, deterministic language that draws custom indicators on an XFlow Charts chart. It is series first and PineScript flavoured. It runs inside your browser and the desktop and phone apps, on the bars your chart is already showing, and it draws through the chart renderer instead of drawing itself.
A script can read every kind of market data the chart holds: the candles, the per price footprint ladder, the individual trades of the tape, the best bid and offer, the depth of book, the life of each individual resting order and every add, change, fill and cancel, the options gamma levels, the markers the Big Trades indicator drew, the zones Effort Zones and Range Absorption drew, and the values of an open built in indicator it extends. It can draw lines, bands, zones, boxes, markers, dots, text, vertical lines, straight segments, recoloured candles, custom volume profiles with a look of their own, filled rectangles with gradients, polygons, footprint style cells, a histogram on the price axis edge, a table in a chart corner, a readout panel and a whole sub panel, and it can raise alerts with a sound and a popup.
A script is plain text. You write it, or an AI writes it, and you paste it into the Custom Indicator Builder in the Indicators window. The builder compiles it as you type and reports one status line. When it reads Compiled, the indicator appears on the chart and any settings the script declares appear underneath the editor.
The five facts that decide whether a script compiles
- Line 1 must be exactly //@xfscript 1. Nothing else identifies the text as XFlow Script.
- Every statement lives on one line. A call may never be split across lines.
- Loops exist and are bounded: for and while run at most 100,000 passes per bar. There are no arrays, no objects, no imports and no property access, and whole bar answers such as tape.largest_size or cell.poc_price are one call, so reach for a loop only when no builtin answers the question.
- Every name you call must be in the builtin tables on this page. Anything else is rejected before the script runs.
- Types are checked on every bar. An int series that resolves to nan stops the run.
//@xfscript 1
indicator("Simple Average")
let length: int = input.int(20, "length", "Length", 2, 400, 1)
plot.line(ta.sma(close, length), "#22C55E", 2, "solid")Paste that into the builder and the chart draws a 20 period average with a Length control under the editor.
Browse the reference
Getting started
Language
- GrammarThe whole grammar and the operator precedence.
- Types and nanType annotations, int and float, and how nan, the absent value, behaves.
- Series, state and historyHow let and var series work, history indexing and the chart globals.
- User functionsDeclaring your own top level functions.
- Loopsfor and while, what a loop body may call and the budgets per bar.
- Settings the user can changeDeclaring settings the user can change.
Market data
Builtins reference
- Builtins: declaration, absent values, textindicator(), absent values, text and the chart.
- Builtins: mathThe math functions.
- Builtins: series mathsMoving averages, indicators and other maths over a series.
- Builtins: time and sessionsDates, times, time zones and sessions.
- Builtins: higher timeframe candlesThe developing candle of a higher timeframe.
- Builtins: colourBuilding and adjusting colours.
- Builtins: candles and the trade tapeBar totals and the individual prints of the trade tape.
- Builtins: the footprint ladderThe footprint ladder: the volume at every price row.
- Builtins: level 1 quotesLevel 1: the best bid and offer.
- Builtins: level 2 depth of bookLevel 2: the aggregated depth of book.
- Builtins: level 3 individual ordersLevel 3: individual resting orders and their events.
- Builtins: options gammaOptions gamma, read per bar.
- Builtins: the Big Trades markersThe markers the Big Trades indicator drew.
- Builtins: Effort Zones and Range Absorption zonesEffort Zones and Range Absorption zones, read by name.
- Builtins: session profiles, trading sessions and the opening rangeSession profiles, Trading Sessions and the opening range.
- Builtins: FVG gaps and the Stop Run, Iceberg and Delta Spike markersFVG gaps and the Stop Run, Iceberg and Delta Spike markers.
- Builtins: levels, stats, flows and candles from the rest of the catalogLevels, stats, flows and candles from the rest of the catalog.
