Flowscript

Indicators and models

The indicators built into Flowscript, sessions and VWAP, market profile, and trained models that fit the same way in a backtest and live.

Moving averages#

sma, ema, wma, rma, hma, dema, tema take (src, len); vwma(src, vol, len) and vwap(price, vol, len) weigh by volume.

Momentum and oscillators#

FunctionGives
rsi(src, len)0 to 100
stoch(close, high, low, len)0 to 100
cci(src, len), mfi(src, vol, len), obv(src, vol)The classic readings
roc(src, len), momentum(src, len)Rate of change (percent) and momentum
macd(src, fast, slow), macdSignal(…, sig), macdHist(…, sig)One function per line

Volatility and bands#

bbUpper(src, len, mult) and bbLower(…) (the middle is sma(src, len)), stddev, zscore, wilderAtr(high, low, close, len) (the ATR charts draw) and trueRange.

Trend#

adx(high, low, close, diLen, adxLen), diPlus, diMinus, supertrend(high, low, close, factor, len) with supertrendDir, and sar(high, low, close, start, inc, max).

Windows and levels#

highest, lowest, rolling_sum, cum, linreg, corr(a, b, len), median, percentile, barssince(cond), valuewhen(cond, src), and pivothigh and pivotlow (known a few bars late, by design).

Sessions and VWAP#

  • periodVwap(price, volume, t, 86400) is the day's VWAP from 00:00 UTC; anchoredVwap starts from any bar; both have σ bands.
  • inSession, inWeekdaySession, sessionOpen, sessionHigh and sessionLow frame a trading session in any city's time.
  • import "std/vwap"; adds what a VWAP trader reads: where price sits in σ, the week's and month's anchors, whether the day is trending, and a failed push into a band.

Market profile#

tpo.poc, tpo.vah, tpo.val, tpo.vpoc, tpo.poorHigh, tpo.singleAbove, tpo.nakedPocAbove and more read the last whole day's (or week's, or the forming session's) time-price profile, the same in a backtest and live.

Trained models#

Models train on the market as the strategy runs, with no look-ahead, and refit on a schedule. The same model is fitted in a backtest and live.

ModelAnswers
ml.linear, ml.ridge, ml.lasso, ml.elasticNet, ml.svrA forecast of y
ml.boostGradient-boosted trees forecasting y
ml.logistic, ml.boostClassifierThe chance y is above zero
ml.svmA signed margin
ml.knnThe mean y of the nearest rows

Each is written ml.<kind>(y, [x1, x2, …], window: n, horizon: h, retrain: r): it learns y h bars after the predictors over the last n rows, refits every r rows, and answers na until its first fit.

Flowscript
// params: window=300, horizon=3, entry=0.002
const close = bars.close(market, interval);
const ret = close[0] / close[1] - 1;
const fwd = close[0] / close[3] - 1;
const f = ml.ridge(fwd, [ret, close / ema(close, 20) - 1, rsi(close, 14)], window: window, horizon: horizon, retrain: 20);
metric("forecast", f);
when (f > entry && !inPosition()) { paper.buyPct({ pct: 50 }); }
when (inPosition() && f < 0) { paper.sell({}); }

The ML forecast starter is a fuller version, with five features.

Liquidations#

On Hyperliquid's BTC, ETH, SOL, HYPE and ZEC perps, liq.* reads where real open positions would be liquidated: the USD of longs within 1, 2, 5 and 10% below the price, shorts above, and the densest cluster each side. Recorded a minute at a time from 2 November 2026.