Your trading rules.
Written clearly.
Flowscript is ftw.trade's language for trading strategies. It reads market data, calculates signals and defines when a strategy acts.
Write it yourself or with your AI. Backtest on real history, inspect each decision, then start on paper.
uses { bars: "^1", paper: "^1" }
const close = bars.close(market, interval);
const fast = ema(close, 12);
const slow = ema(close, 26);
when (crossover(fast, slow) && !inPosition()) { paper.buy({ quote: 100 }); }
when (crossunder(fast, slow) && inPosition()) { paper.sell({}); }
metric("fast", fast);
metric("slow", slow);Two moving averages. Buy on a cross above; sell on a cross below. Use a spot price feed to try this example.
Read it line by lineRead the market
Closing prices arrive as a series: one value for each completed bar.
Describe the condition
Built-in indicators calculate the averages. A crossing becomes a signal.
Say when to act
when fires as a condition turns true. Metrics show the values behind the decision.
See the moment your rules take over.
Data keeps arriving. Your strategy waits for a completed bar, checks its rules, then acts or waits.
01 Receive data
03 Evaluate rules
fast & slowcrossover(fast, slow)!inPosition()The same rules as the example above.
04 Act or wait
paper.buy({ quote: 100 })A paper buy needs both a cross above and no position.
Spot prices collect into market bars.
Illustrated events, not live data. Each cycle is an independent example on closed bars.A short guide, then as deep as you need.
Follow the introduction from top to bottom, or go straight to the part you need.
Flowscript in five minutes
Flowscript is a language for writing trading rules. Read a complete strategy, understand each line, then check it, backtest it and run it on paper in ftw.trade.
02Values, series and na
The rules of Flowscript on one page: values and series, na, expressions, functions, folds, enums and match, phases and libraries.
03Triggers and orders
When a strategy acts (when, while and the combinators) and every order it can place on spot, perps, liquidity and protocols.
04Indicators 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.
05Modules and imports
A strategy's uses line names what it reads and does. Every module (market data, books, venues, protocols, std contracts and your own libraries) with the line that imports it and a working example.
06Tests and risk limits
Write tests that prove a strategy buys the move it should and holds still when it should, and an invariants block that refuses entries once it loses too much.
07Full language reference
Where to find every Flowscript function, rule and error code, and the module catalog, in full.
Try your first strategy.
Open the editor on ftw.trade, or connect your AI. Check the code, backtest it and run on paper before choosing to use real funds.