Help center · Indicators and FlowScript

FlowScript quick reference

The language on one page: syntax, history, functions, drawing, sessions, delta, other timeframes and strategies.

FlowScript runs once per bar, oldest bar first. Every name holds a value per bar. If you know Pine Script or Python, it will feel familiar.

indicator("EMA Cross", overlay = true)

fast = ema(close, 9)
slow = ema(close, 21)

plot(fast, "Fast", color = amber)
plot(slow, "Slow", color = violet)
signal(crossover(fast, slow), "Bull")

Basics

  • Comments start with //. One statement per line. Blocks (if, else, for, while, def) are indented by 4 spaces.
  • Assign with = and change with +=, -=, *=, /=.
  • History: close[1] is the previous close, x[2] two bars ago.
  • var count = 0 keeps its value from bar to bar.
  • na means no value. Math with na gives na. Test with na(x), replace with nz(x).
  • Operators: + - * / %, == != < <= > >=, and or not, cond ? a : b.
  • Named settings come after plain values: plot(x, "Title", color = red, width = 2).

Functions and data

  • Your own functions: def mid(a, b) => (a + b) / 2, or a def with an indented body ending in return.
  • Lists [1, 2, 3] and maps map(), with push, pop, sort, sum, avg, median, percentile, get, keys and more.
  • 203 built-in functions: moving averages, RSI, MACD, Bollinger Bands, ATR, Supertrend, pivots, highest and lowest, crossovers and many more.

Drawing

  • plot(), plotcandle(), hline(), fill(), bgcolor(), barcolor(), signal() and alert() draw per bar.
  • label(), line(), box(), polyline() and table() create objects you can keep, move with update() and remove with delete().

Sessions, delta and other timeframes

  • Session values in New York time: rth, premarket, new_session, minutes_since_open, pdh, pdl, pdc, onh, onl, pmh, pml, ib_high, ib_low, pwh, pwl, in_session("0930-1030").
  • Order flow: bar_delta(), cum_delta(), buy_volume(), sell_volume() use real trade sides when the chart has them, otherwise an estimate.
  • Profiles and volume: vwapbands(), profile() (POC and value area), rvol(), rvol_time().
  • Other timeframes and symbols: htf("60", ema(close, 20)) and security("QQQ", "5", close) use completed bars only, so they never repaint. The timeframe or symbol can be text, an input, or a formula of inputs worked out before the script runs, such as tf = input("Timeframe", "15") then htf(tf, close).
  • Swing points: pivothigh(5, 5) finds highs in the bars’ highs; give a series first, pivothigh(rsi(close, 14), 5, 5), to find them in anything.

Inputs

length = input("Length", 14) becomes a setting traders can change in the indicator’s settings dialog. group = "Signals" puts settings under a heading, inline = "colors" puts the settings that share it on one row, and tooltip = "…" adds a help bubble.

The Style tab

Like Pine, every script gets a Style tab in its settings with no extra code: each plot, level, fill, signal, candle set, background and bar color has a show/hide toggle, a swatch for every fixed color the code names (both colors of close > open ? green : red, the color inside fade(blue, 12)) and, for plots, a line width. Colors that come from an input() are changed on the Inputs tab instead.

Functions that remember

Averages, atr(), crossover(), highest(), barssince() and the like keep their own history, so they have to run on every bar. Calculate them on their own line and use the result inside if blocks and loops; Flow Studio warns you when one is called inside a block.

Take the FlowScript course. FlowScript course

Related