# Metrand strategy format

Metrand runs trading strategies written as JSON graphs. This document explains that format and lists every
operation the engine accepts. Attach it to a chat with an AI assistant (ChatGPT, Claude, Gemini or another) so the
assistant can write a graph Metrand will accept; it works just as well for writing a graph by hand.

The op reference near the end was generated from Metrand's engine on 2026-11-21. The engine checks every graph
when it is imported, validated, backtested or saved, so where this document and Metrand disagree, Metrand is right.

A graph gets into Metrand through **New strategy → Import a file**, which takes a `.json` file or the JSON pasted
into its text box, or through the strategy editor's **Graph** view, which takes pasted JSON on its **{ } JSON** tab. From there it can be backtested on
Binance USDⓈ-M or Bybit perpetual futures history, paper-traded on the live market, and, on a paid plan, run live
on the user's own exchange account.

Nothing in this document, and nothing an assistant writes with it, says whether a strategy will make money. A
backtest measures what a strategy would have done in the past, costs included. It does not predict what it will do
next.

## Instructions for the assistant

1. Reply with the complete graph as one JSON object in a single code block, and nothing else: no comments inside
   the JSON, no trailing commas, no partial graphs.
2. If the request is unclear, or cannot be built from the ops in the reference, ask the user instead of guessing.
3. Use only the kinds, ops, ports and params listed in the op reference, spelled exactly as there. Write an op's
   own name, not one of its aliases.
4. Write every param of every node with a value, even when you want the listed default.
5. On `decision.enter_long` and `decision.enter_short`, write `"obi_min": -1` unless the user asks for an
   order-book filter. A backtest refuses any graph that filters on the order book.
6. Wire each edge into a port the target op lists, carrying the type that port expects. The engine refuses an
   edge into a port the op does not read, but it does not check types: a wrong type leaves the strategy never
   trading.
7. Set `output` to the id of the last node of the decision chain: a decision, risk or execution node.
8. Prefer ops marked "every plan" in the reference. An imported graph with an op marked "Expert plan" needs the
   Expert plan; if the idea needs one, ask the user first whether they have it.
9. Keep strategies small: few conditions, few params, round numbers. Fewer numbers to tune means fewer ways to fit
   the past by accident.
10. When the user pastes an error from Metrand, look it up under "Errors and how to fix them", fix the graph and
    reply with the whole corrected graph.
11. Never claim that a strategy is profitable, and never predict its returns.

## The graph

### The envelope

```json
{
  "nodes": [
    { "id": "price", "kind": "source", "op": "candles" },
    { "id": "ema_fast", "kind": "indicator", "op": "ema", "params": { "period": 20 } }
  ],
  "edges": [
    { "from": "price", "to": "ema_fast", "port": "price" }
  ],
  "output": "exec"
}
```

- `nodes`: required, from 1 to 200 nodes. Each node has:
  - `id`: a string, unique in the graph. Short readable ids help: `price`, `ema_fast`, `entry`, `exec`.
  - `kind`: one of the node kinds below.
  - `op`: the operation, from the reference. Required.
  - `params`: an object holding the op's params. Numbers are JSON numbers (`20`, not `"20"`), choices are
    strings, and a model's `weights` is an array of numbers. A key the op does not list is an error.
  - `instrument`: optional, on `source` nodes only, to read another market (see "Reading another market").
- `edges`: up to 400. Each edge sends the value of node `from` into the input port `port` of node `to`.
- `output`: required. The id of the node whose decision the strategy acts on. It must be a `decision`, `risk` or
  `execution` node.

Use no other fields. Fields Metrand does not know are dropped when the strategy is saved.

### Node kinds

| Kind | What it does |
| --- | --- |
| `source` | Market data: the bar's close (`candles`), its open, high, low and volume, and the order-book imbalance. |
| `indicator` | A computed series: moving averages, oscillators, volatility and volume measures. Most read a `price` input. Bar indicators (ATR, NATR, Stochastic, Williams %R, CCI, Donchian, OBV, VWAP, VWMA, relative volume) read the bar itself and take no input. |
| `transform` | Arithmetic on series (add, subtract, multiply, divide, min, max, scale), a delay (`lag`) and the bar's time (`clock`). |
| `rule` | A condition, true or false: thresholds, crossings, comparisons of two series, AND, OR, NOT. |
| `state` | Memory: `cooldown` (wait some bars after an entry signal) and `position` (the strategy's own open position). |
| `model` | A small scoring model over wired features. |
| `decision` | What to do: enter long, enter short, either side, close the position (a managed exit), or a grid. |
| `risk` | Changes a decision: order size, stop-loss and take-profit, risk per trade, an expected-value filter. |
| `execution` | How the entry order is placed: post-only maker or market. |
| `basket` | Settings of a basket that picks its own markets: which markets (`universe`) and when the whole basket stops (`guard`). Wired to nothing; see "Baskets that pick their own markets". |

`notification` is a reserved kind with no ops yet; a node of that kind does not compile.

### Values and ports

Every node produces one value per bar, and an edge carries it to one input port of another node. The reference
gives each port a type and each op the type it emits:

- `float`: a number. The `candles` source emits `price` and the order-book source emits `obi`; both are numbers
  and go into `float` ports.
- `bool`: true or false. Rules emit it, and `gate`, `want`, `long`, `short` and the `in0`, `in1` … ports take it.
- `decision`: a decision, made by a decision node and passed along through risk and execution nodes on their
  `decision` port.

`state.position` is listed as emitting `float`, but its fields `in_position`, `flat`, `long` and `short` are true
or false, while `bars`, `upnl`, `entry` and `qty` are numbers. Wire each one where its value belongs.

A value can also be empty: an indicator is empty until it has seen enough bars (its warmup), and a node whose
input is missing or empty is empty too. Empty means unknown, not false:

- a rule over an empty value is empty, and so is `rule.not` of one;
- `rule.all` is false as soon as one input is false, true when all are true, and empty otherwise;
- `rule.any` is true as soon as one input is true, false when all are false, and empty otherwise;
- `rule.cross_up` and `rule.cross_down` are also empty on the first bar both lines exist, since there is no earlier
  bar to cross from;
- an entry whose gate is empty holds.

Each input port takes one edge. When two edges go into the same port, the first one in `edges` is used and the
others are ignored. The exceptions are `rule.all`, `rule.any`, `model.logistic` and `model.threshold_score`, which
read every edge wired into them whatever its port name; name their ports `in0`, `in1`, `in2` … (rules) and `f0`,
`f1`, `f2` … (models). A model's `weights` line up with its edges in the order they appear in `edges`.

The graph must have no cycles.

### The decision chain

The output of a graph is a decision, made fresh on every bar. A decision carries:

- what to do: hold, enter long, enter short, or exit;
- `quote_usdt`: the size of the position in USDT (its value, not the margin behind it);
- `sl_bps` and `tp_bps`: the stop-loss and take-profit distances in basis points of the entry price
  (100 bps = 1%);
- how the entry order is placed: post-only maker or market.

It is built along a chain of nodes, each one taking the decision on its `decision` port and passing it on:

1. **An entry decision** (`decision.enter_long`, `decision.enter_short` or `decision.enter_long_short`) enters on
   a bar where its trigger input is true, and holds otherwise. It sets the size, the stop and the target from its
   params, and makes the entry a post-only maker order.
2. **Optionally, a managed exit** (`decision.exit`). While the strategy holds a position and the exit's `gate` is
   true, it replaces the decision with a close of the whole position at market. While flat, it passes the entry
   decision through unchanged.
3. **Optionally, risk nodes**, in any number, each changing part of the decision:
   - `risk.fixed_risk` sets the size, and the stop and target when its `sl_bps` and `tp_bps` are written.
   - `risk.dynamic_tp_sl` sets the stop to `sl_mult` × its `vol` input, kept between `min_sl_bps` and
     `sl_cap_bps`, and the target to the stop × `rr`. Feed `vol` with `indicator.natr`, which is in basis points.
     Until `vol` has a value, the decision keeps the stop and target it had.
   - `risk.risk_per_trade` sizes the position so that a stop-out costs `risk_usdt`: size = `risk_usdt` ÷
     (`sl_bps` ÷ 10 000), at most `max_quote_usdt`. Put it after the node that sets the stop.
   - `risk.edge_gate` holds an entry whose expected value, from a model's `p_win`, is below `min_ev_bps`.
4. **Optionally, an execution node**: `execution.market` makes the entry a market order; `execution.maker` keeps it
   post-only. Without one, the entry is post-only.

Each node sees the decision as the previous one left it, so order matters: a stop set by `risk.dynamic_tp_sl` is
overwritten by a later `risk.fixed_risk` that writes `sl_bps`. The `output` is the last node of the chain.

A common shape:

```
source.candles → indicators → rules → rule.all → state.cooldown → decision.enter_long
  → decision.exit → risk.dynamic_tp_sl → risk.risk_per_trade → execution.market   (output)
```

## How a strategy runs

### Bar by bar

- A strategy decides on closed bars of one timeframe: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h or 1d, or range bars. The
  timeframe is chosen when it is backtested or launched, not in the graph.
- Every lookback counts bars of that timeframe: an EMA of 20 spans 20 hours on 1h bars and 20 days on 1d bars.
- When a bar closes, every node is evaluated in order and the output's decision is read. A `price` input is the
  bar's close.
- An order decided at a bar's close is sent after that close, so in a backtest it trades at the next bar's open.

### One position at a time

- A strategy holds at most one position. While it holds one, or while an entry order is still waiting to fill,
  a new entry on the same side is ignored: there is no adding to a position.
- An entry on the other side turns the position around: at the next open the position is closed and the entry on
  the other side is sent. `decision.enter_long_short` is the op for a strategy that trades both sides.
- A rule that stays true (such as `rule.above` or `rule.gt`) used as an entry trigger enters again right after a
  stop-out, as soon as the strategy is flat. Use `rule.cross_up` or `rule.cross_down`, which are true only on the
  bar of the crossing, or a `state.cooldown`, when that is not what you want.
- `state.cooldown`: when its `want` input is true it passes that one bar through, then answers false for `bars`
  bars, whether or not an entry followed.

### Exits

- Every position gets a stop-loss and a take-profit from its decision, measured from the entry price. For a long,
  the stop is entry × (1 − `sl_bps` ÷ 10 000) and the target entry × (1 + `tp_bps` ÷ 10 000); a short mirrors them.
- There is no switch to turn the take-profit off. To leave exits to the stop and to signals, set `tp_bps` out of
  reach: the shipped trend template uses 100000 (1000%). A short's target 100% or more below its entry is not
  placed at all.
- A managed exit closes the position at market on a signal: wire a condition into the `gate` of `decision.exit`.
  Typical gates are a time stop (`state.position` with `field` `bars` into `rule.ge`), the opposite crossing, or a
  loss or profit level (`state.position` with `field` `upnl`, in USDT).
- `state.position` fields: `in_position`, `flat`, `long`, `short` (true or false); `bars` (how many bars the
  position has been held); `upnl` (unrealized profit or loss in USDT at the bar's close, before fees); `entry`
  (entry price, empty when flat); `qty` (position size in coins).

## How a backtest fills and charges

- **Data.** Real closed candles from Binance USDⓈ-M futures or Bybit perpetuals. How many bars one backtest
  replays depends on the user's plan.
- **Account.** 1,000 USDT at 1× leverage unless the user changes the costs. The position size has to fit the
  account: an entry larger than equity × leverage fails the whole backtest with `backtest_unfunded` (see below).
- **Size.** `quote_usdt` ÷ price, rounded down to the market's lot step, and raised to the exchange's minimum
  quantity and minimum order value when it is below them. The exchange's own lot rules are used when they can be
  read, generic ones otherwise; the report says which.
- **Market entries** trade at the next bar's open, on the ask for a buy and the bid for a sell of a book the
  backtest builds 1 bp either side of the price, plus the slippage setting, and pay the taker fee.
- **Maker entries** (the default, and `execution.maker`) rest as a post-only order two price steps of the market
  below the bid for a long (above the ask for a short), as quoted at the close of the bar that decided them, the way
  a live run rests them; every post-only rung of a ladder does the same. Where the price step is not known, 2 bps
  stand in for it, and the result says which (`report.config.maker_offset`). The order goes to the
  exchange at the next bar's open, where it is rejected if it would trade at once (post-only), and fills at its own
  price, with the maker fee and no slippage, once a bar trades below it (above, for a short): a trade exactly at
  the price is a touch, not a fill. Until it fills, the strategy takes no other entry. As a live run does, the
  backtest cancels an entry that has not filled within one bar. Use `execution.market` for an entry that must
  happen on the bar after the signal.
- **Inside a bar.** A candle does not say whether its high or its low came first, so the backtest walks each bar
  both ways, open → low → high → close and open → high → low → close. Along each, the price meets the stop, the
  target, the liquidation price and resting orders in the order it reaches them, and each fill moves the stop and
  target before the price goes on. The walk that leaves the account worse is kept, and a trade it decided is
  marked "either way". A backtest given finer candles (1m under 15m bars) walks those instead, so what happened
  inside the bar is read rather than assumed.
- **Exits.** The stop and the target leave at market: they pay the slippage setting and the taker fee. A bar that
  opens beyond the stop fills it at that open, not at the stop price. A managed exit or a reversal trades at the
  next bar's open. A position still open when the data ends is closed at the last close.
- **Fees.** The standard costs are the exchanges' base-tier perpetual fees, taker / maker: Binance 0.05% / 0.02%,
  Bybit 0.055% / 0.02%, with 0.01% slippage on every market fill. The user can double or triple them, or set
  their own. Every fill pays a fee, the entry and the exit.
- **Funding.** Perpetual funding is charged at every settlement the exchange published in the window, on the
  position held through it (a settlement inside a bar, on the position the bar opened with): a long pays a positive
  rate and is paid a negative one, a short the reverse. When the funding history cannot be read, the report says
  funding is not included.
- **Leverage.** Above 1×, a position that reaches its liquidation price is liquidated, and the account loses its
  whole balance, as on the exchange. The price follows the market's own margin schedule (maintenance margin by
  position size, read from the exchange daily; `report.config.margin_tiers` names it and the day it was read). An
  entry that would take the position past what the market allows at the leverage is not opened
  (`entries_skipped_position_limit`), and a leverage above the market's maximum is refused. Without a schedule a
  flat 0.4% stands in (`margin_tiers: "flat"`).
- **A round trip costs** 0.12% of the position at standard costs with market orders (0.05% fee and 0.01% slippage
  on each side), plus 1 bp of spread each way. A stop or target of a few tenths of a percent leaves little room.

### Warmup

An indicator gives no value until it has seen enough bars, and nothing trades on an empty value. Moving averages
start the way TA-Lib and TradingView start them: the first value is the plain average of the first `period` bars.

The engine works out a strategy's warmup from its graph. A window (SMA, Bollinger, Donchian, ROC …) needs its
`period`. An exponential average needs more, so that the bars it started on stop showing in its value: 3 periods
for an EMA (also inside MACD, PPO, TSI, DEMA and TEMA, per stage) and 5 for Wilder's averages (RSI, ATR, NATR, RMA).
An indicator of an indicator needs both: an EMA(10) of an RSI(14) warms up over 5 × 14 + 3 × 10 = 100 bars. A
cooldown adds nothing. A param left out counts at its default.

A paper or live run on time bars that reads no other market warms up on up to 1,000 recent closed bars before its
first decision; one on range bars, on a week of candles. A backtest warms up the same way before its window, on 1,000
bars or the warmup above if it is longer (a week of candles for range bars), and trades from the window's first bar;
the result says how many bars it warmed on (`warm_bars`). Each period, each market of a basket and each part of the
optimizer warms on the bars before it.

## Reading another market

A `source` node can read another market than the one the strategy trades, for a signal such as "trade ETH when BTC
is above its 200-day average":

```json
{ "id": "btc", "kind": "source", "op": "candles", "instrument": "binance:BTCUSDT" }
```

- `instrument` is `exchange:SYMBOL`, with `binance` or `bybit` as the exchange. Anything else fails to compile.
- The strategy still trades the market it is backtested or launched on.
- A backtest replays at most 4 other markets, over the same bars, from Binance or Bybit history.
- A paper run can read other markets on the same exchange only. A live run refuses a graph that reads another
  market, and so do range bars.
- Nodes fed by another market's source update when that market's bar closes.

## Baskets that pick their own markets

A strategy made for a basket can name the rule its markets are picked by instead of a list of markets. Two `basket`
nodes, at most one of each, wired to nothing:

```json
{ "id": "universe", "kind": "basket", "op": "universe",
  "params": { "by": "turnover", "top": 20, "window_days": 30, "refresh": "quarter", "min_age_days": 60 } }
{ "id": "guard", "kind": "basket", "op": "guard", "params": { "max_drawdown_pct": 25, "daily_loss_pct": 5 } }
```

- `basket.universe` picks the `top` markets by `by` over the last `window_days` days: `turnover` (USDT traded),
  `turnover_change` (that turnover against the window before), `volatility` or `return`. It picks again at the start
  of every `refresh` unit (`day`, `week`, `month`, `quarter`, in UTC). Only markets listed at least `min_age_days`
  days and trading on at least `min_turnover_usdt` a day are picked; `include` and `exclude` list symbols that are
  always in or never in. Futures on stocks, indexes and commodities, and stablecoin pairs, are never picked.
- `basket.guard` stops the whole basket, closing every position, when its equity falls `max_drawdown_pct` % from its
  peak or `daily_loss_pct` % of its capital since the UTC day began; 0 turns either off.
- A backtest of such a strategy picks the basket on its first day and at each refresh from the markets of that time,
  delisted ones included, replays every market over each stretch it spent in the basket (closing its position, with
  costs, when it leaves) and adds them up into one account. It runs in the background and costs one backtest per
  market the basket holds at once.
- A launch starts the markets picked today; at each refresh the runs of markets that left are stopped, closing what
  they hold, and the markets that entered are launched with the same settings.

Three more ops are made for baskets but work in any graph:

- `source.basket_rank` ranks the basket's markets at each bar by `return`, `return_vol`, `funding`, `turnover`
  (USDT traded over `lookback` bars), `turnover_change` or `volatility`.
- `risk.side_scale` sizes longs and shorts apart: `long_pct` and `short_pct` of the size the decision carries, or
  bar by bar from its `long` and `short` inputs. A side at 0 % enters nothing.
- `transform.choose` turns a condition into a number: `then` while its `when` input is true, `else` while it is
  false, or the `a` and `b` inputs when they are wired. Wired into `risk.side_scale`, it can, for example, halve the
  shorts while BTC is above its 100-day average.

## Open interest, positioning and liquidations

Three sources read what the exchange's futures statistics and its forced orders say about the traded market. Each
takes no `instrument`: it reads the market the strategy trades.

```json
{ "id": "oi", "kind": "source", "op": "open_interest", "params": { "unit": "usd" } }
{ "id": "crowd", "kind": "source", "op": "positioning", "params": { "field": "top_positions" } }
{ "id": "liq", "kind": "source", "op": "liquidations", "params": { "side": "longs" } }
```

- `source.open_interest` (alias `oi`) is the open interest in USDT (`unit: usd`) or in contracts (`unit: contracts`).
- `source.positioning` (alias `long_short`) is a ratio above 0: `accounts` is all accounts long over accounts short,
  `top_accounts` and `top_positions` are the top traders' accounts and positions, `takers` is the takers' buy volume
  over their sell volume. Above 1, the long or buying side is larger.
- `source.liquidations` (alias `liq`) is the USDT of positions force-closed during the bar: `longs`, `shorts`,
  `both` or `net` (longs less shorts). A bar without any reads 0.
- The exchange publishes open interest and the ratios in 5-minute steps, each once its 5 minutes are over. A bar
  reads the last step that ended at least 5 minutes before it closes, so a run finds it in time and a backtest reads
  exactly what the run would have. On 5-minute bars that is the step of the 5 minutes before the bar.
- A change is built from the level with the indicators: `indicator.roc` over `source.open_interest` is open interest
  growing or shrinking; `indicator.zscore` over `source.liquidations` marks a flush far above the usual.
- Binance only, on bars of a day or shorter that divide a day (not range bars). Open interest and the ratios have
  history from 2025 for every market that was among the 30 largest by turnover at the start of a month; another
  market has what the platform recorded of it, from when it first did. Liquidations go back only to when the
  platform started recording them: the exchange publishes no history of them. A backtest whose window starts before
  a series does is refused, with the date it can start from, before it is charged.

## Comparing two values

`rule.compare` takes `eps` as the margin `a` must clear: `gt` is `a > b + eps`, `ge` is `a ≥ b + eps`, `lt` is
`a < b − eps`, `le` is `a ≤ b − eps`. `rule.approx_eq` is true when `|a − b| ≤ eps`; at `eps` 0 it is exact equality.

## Units

| Value | Unit |
| --- | --- |
| `sl_bps`, `tp_bps`, `min_sl_bps`, `sl_cap_bps`, `spacing_bps`, `fee_bps`, `min_ev_bps` | basis points of price: 100 = 1% |
| `quote_usdt`, `total_usdt`, `risk_usdt`, `max_quote_usdt` | USDT of position value |
| `indicator.roc` | percent change over `period` bars: 0.5 = 0.5% |
| `indicator.natr` | basis points of price: 100 = 1% |
| `indicator.atr`, `indicator.rvol`, `indicator.macd` (histogram), moving averages, Donchian lines | price |
| `indicator.rsi`, `indicator.stoch` | 0 to 100 |
| `indicator.stochrsi` | 0 to 100, unsmoothed (TradingView's %K before its average) |
| `indicator.willr` | −100 to 0 |
| `indicator.cmo` | −100 to 100 |
| `indicator.bbpct` | 0 at the lower band, 1 at the upper; below 0 or above 1 outside the bands |
| `source.orderbook_imbalance` | −1 (only offers) to 1 (only bids) |
| `source.open_interest` | USDT of open positions (`unit: usd`) or contracts |
| `source.positioning` | a ratio: 1 = as many long as short |
| `source.liquidations` | USDT force-closed during the bar |
| `transform.clock` | `minute_of_day` 0 to 1439, `hour` 0 to 23, `day_of_week` 0 (Monday) to 6 (Sunday), of the bar's open time in UTC shifted by `tz_offset_min` |
| `state.position` `upnl` | USDT |

## What works where

| Graph | Backtest | Paper run | Live run |
| --- | --- | --- | --- |
| Filters on the order book (`obi_min` above -1, or a rule reading `source.orderbook_imbalance`) | refused: candles carry no order book | yes | yes |
| Reads another market (`instrument`) | yes, up to 4 | same exchange only | refused |
| `decision.grid` with more than one level | yes | places no orders | places no orders |
| Picks its own markets (`basket.universe`) | Binance, as a background job on daily or shorter bars | Binance | Binance, within the exchange's capacity for live runs |
| Reads open interest, positioning or liquidations | Binance, from the date each series starts | Binance | Binance |
| Everything else in the reference | yes | yes | yes |

A paper run counts an order as filled as soon as it is placed: a market order at the best bid or offer, a maker
order at its own price. It checks the stop and target on every price update, and keeps a position open until one
of them is hit or the strategy closes it.

## Errors and how to fix them

Metrand shows the engine's own message. The ones below are what it says, with what to change.

| Message | What to change |
| --- | --- |
| `parse error: …` | The JSON is not a graph: check `nodes`, `edges` and `output` are there and that the JSON is valid (no comments, no trailing commas). |
| `node 'X': unknown kind 'K'` | Use one of the kinds listed above. |
| `node 'X': kind 'K' requires an op` | Add `op`. |
| `node 'X': no backed op 'kind.op'` | That op does not exist for that kind. Check the reference: the kind matters too (`indicator.ema`, not `rule.ema`). |
| `edge references unknown node 'X'` | An edge's `from` or `to` names no node. Fix the id. |
| `graph error: DuplicateId("X")` | Two nodes share an id. |
| `graph error: Cycle` | The edges go round in a loop. Remove one. |
| `graph error: UnknownOutput("X")` | `output` names no node. |
| `graph error: OutputNotDecision("X")` | `output` must be the last decision, risk or execution node, not an indicator or rule. |
| `node 'X': param 'K' must be a non-negative integer` (or `a number`, `an integer`, `a string`, `a decimal number`, `an array of numbers`) | Write the value with that type: `20`, not `"20"` or `20.5`. |
| `node 'X': OP has no param 'K'` | Remove the param, or use the name the reference gives. |
| `node 'X': kind.op requires param 'K'` | Add the param. |
| `node 'X': param 'K' = V is out of range [MIN, MAX]` | Bring the value inside the range. The reference's "Hard bounds" column has it. |
| `node 'X': param 'K' = 'V' must be one of [...]` | Use one of the listed choices. |
| `node 'X': instrument 'V' is not a canonical 'exchange:symbol'` | Write `binance:SYMBOL` or `bybit:SYMBOL`. |
| `node 'X': min_sl_bps (A) must not exceed sl_cap_bps (B) …` | The stop floor is above the stop cap. Swap them or lower the floor. |
| `this strategy filters on order-book imbalance, and a backtest has only OHLCV bars …` | Write `"obi_min": -1` on the entry decision and remove any rule reading `source.orderbook_imbalance`. |
| `backtest_unfunded: the strategy asked to open N USDT of notional against M USDT of equity …` | The position is larger than the backtest account can carry. Lower `quote_usdt` (or `max_quote_usdt`), or raise the account or leverage in the backtest costs. |
| `instrument 'X' must read exchange:SYMBOL` | Same as the canonical instrument error above. |
| `X cannot be backtested: only Binance and Bybit history is available` | Read a Binance or Bybit market. |
| `this reads N other markets; a backtest can replay at most 4` | Read fewer other markets. |
| `The Expert graph editor is not included in your plan — upgrade to use it.` | The graph uses an op marked "Expert plan". Use ops marked "every plan", or the Expert plan. |
| `node 'X': kind.op has no input port 'p'; its ports are [...]` | Wire the edge into one of the ports listed. |
| The backtest runs but shows no trades | Check port names and types against the reference, the units of thresholds (ROC is in percent, NATR in basis points, RSI from 0 to 100), and that the market has history before the window to warm up on. |

## Writing strategies that hold up

- Fewer numbers are better. Each param tuned to the past is a chance to fit noise. Three or four tunable numbers
  are plenty.
- Prefer daily or 4-hour bars to minute bars. Costs are the same per trade at every timeframe, and short bars
  make many small trades whose edge the costs eat.
- Make stops and targets wide compared with the round-trip cost of about 0.12%.
- Test the same graph on several periods and on a basket of markets in Metrand, not on the one window where it
  looks best. A result that only holds in one period or on one coin is usually luck.
- Look at the break-even cost in the backtest report: the cost per fill at which the result would be zero. If it
  is close to what the backtest already paid, the result lives on cheap execution.
- Rerun the backtest with costs ×2. A strategy worth trading survives dearer fills.
- Count the trades. Under about thirty, a win rate or profit factor is mostly chance.

## Complete examples

These are the templates Metrand ships, exactly as a new strategy starts from them. Each compiles as it is.

### EMA crossover

Enters long on the bar where the 5-bar EMA crosses above the 20-bar EMA, then lets 3 bars pass before another
entry signal can go through. The entry decision writes only `obi_min` and keeps its defaults for the rest: a
25 USDT position, a stop 30 bps (0.3%) below the entry and a target 45 bps above it. With no execution node, the
entry is a post-only maker order, and the decision node itself is the output. A new graph should write all four
params.

```json
{
  "nodes": [
    {"id":"price","kind":"source","op":"candles"},
    {"id":"ema_fast","kind":"indicator","op":"ema","params":{"period":5}},
    {"id":"ema_slow","kind":"indicator","op":"ema","params":{"period":20}},
    {"id":"cross","kind":"rule","op":"cross_up"},
    {"id":"cool","kind":"state","op":"cooldown","params":{"bars":3}},
    {"id":"decide","kind":"decision","op":"enter_long","params":{"obi_min":-1.0}}
  ],
  "edges": [
    {"from":"price","to":"ema_fast","port":"price"},
    {"from":"price","to":"ema_slow","port":"price"},
    {"from":"ema_fast","to":"cross","port":"fast"},
    {"from":"ema_slow","to":"cross","port":"slow"},
    {"from":"cross","to":"cool","port":"want"},
    {"from":"cool","to":"decide","port":"gate"}
  ],
  "output": "decide"
}
```

### Momentum

Enters long when the 12-bar EMA crosses above the 26-bar EMA while the MACD histogram (12, 26, 9) is above 0; the
two conditions are combined by `rule.all` and pass through a 3-bar cooldown. The position is 25 USDT with a
30 bps stop and a 45 bps target, entered with a post-only maker order.

```json
{
  "nodes": [
    {"id":"src_price","kind":"source","op":"candles"},
    {"id":"i1","kind":"indicator","op":"ema","params":{"period":12}},
    {"id":"i2","kind":"indicator","op":"ema","params":{"period":26}},
    {"id":"i3","kind":"indicator","op":"macd","params":{"fast":12,"slow":26,"signal":9}},
    {"id":"c1","kind":"rule","op":"cross_up"},
    {"id":"c2","kind":"rule","op":"gt","params":{"threshold":0}},
    {"id":"gate","kind":"rule","op":"all"},
    {"id":"cool","kind":"state","op":"cooldown","params":{"bars":3}},
    {"id":"decide","kind":"decision","op":"enter_long","params":{"obi_min":-1,"quote_usdt":25,"sl_bps":30,"tp_bps":45}},
    {"id":"exec","kind":"execution","op":"maker"}
  ],
  "edges": [
    {"from":"src_price","to":"i1","port":"price"},
    {"from":"src_price","to":"i2","port":"price"},
    {"from":"src_price","to":"i3","port":"price"},
    {"from":"i1","to":"c1","port":"fast"},
    {"from":"i2","to":"c1","port":"slow"},
    {"from":"i3","to":"c2","port":"x"},
    {"from":"c1","to":"gate","port":"in0"},
    {"from":"c2","to":"gate","port":"in1"},
    {"from":"gate","to":"cool","port":"want"},
    {"from":"cool","to":"decide","port":"gate"},
    {"from":"decide","to":"exec","port":"decision"}
  ],
  "output": "exec"
}
```

### Mean reversion

Buys a dip: Bollinger %B (20 bars, 2 standard deviations) below 0.05, so price is at or under the lower band, and
the 14-bar RSI under 30, with a 5-bar cooldown. The entry decision sets 25 USDT, a 40 bps stop and a 60 bps
target, and `risk.fixed_risk` after it sets the same three values again: a risk node overrides what the decision
set. The entry is a post-only maker order.

```json
{
  "nodes": [
    {"id":"src_price","kind":"source","op":"candles"},
    {"id":"i1","kind":"indicator","op":"bbpct","params":{"period":20,"k":2}},
    {"id":"i2","kind":"indicator","op":"rsi","params":{"period":14}},
    {"id":"c1","kind":"rule","op":"lt","params":{"threshold":0.05}},
    {"id":"c2","kind":"rule","op":"lt","params":{"threshold":30}},
    {"id":"gate","kind":"rule","op":"all"},
    {"id":"cool","kind":"state","op":"cooldown","params":{"bars":5}},
    {"id":"decide","kind":"decision","op":"enter_long","params":{"obi_min":-1,"quote_usdt":25,"sl_bps":40,"tp_bps":60}},
    {"id":"r1","kind":"risk","op":"fixed_risk","params":{"quote_usdt":25,"sl_bps":40,"tp_bps":60}},
    {"id":"exec","kind":"execution","op":"maker"}
  ],
  "edges": [
    {"from":"src_price","to":"i1","port":"price"},
    {"from":"src_price","to":"i2","port":"price"},
    {"from":"i1","to":"c1","port":"x"},
    {"from":"i2","to":"c2","port":"x"},
    {"from":"c1","to":"gate","port":"in0"},
    {"from":"c2","to":"gate","port":"in1"},
    {"from":"gate","to":"cool","port":"want"},
    {"from":"cool","to":"decide","port":"gate"},
    {"from":"decide","to":"r1","port":"decision"},
    {"from":"r1","to":"exec","port":"decision"}
  ],
  "output": "exec"
}
```

### Volatility breakout

Enters long when price has risen more than 0.2% over 10 bars (`indicator.roc` is in percent), with a 5-bar
cooldown. `risk.dynamic_tp_sl` replaces the decision's stop with 1.5 × the 14-bar NATR (in basis points), kept
between 10 and 300 bps, and sets the target at twice the stop. The entry is a market order.

```json
{
  "nodes": [
    {"id":"src_price","kind":"source","op":"candles"},
    {"id":"i1","kind":"indicator","op":"roc","params":{"period":10}},
    {"id":"i2","kind":"indicator","op":"natr","params":{"period":14}},
    {"id":"c1","kind":"rule","op":"gt","params":{"threshold":0.2}},
    {"id":"cool","kind":"state","op":"cooldown","params":{"bars":5}},
    {"id":"decide","kind":"decision","op":"enter_long","params":{"obi_min":-1,"quote_usdt":25,"sl_bps":50,"tp_bps":120}},
    {"id":"r1","kind":"risk","op":"dynamic_tp_sl","params":{"sl_mult":1.5,"rr":2,"min_sl_bps":10,"sl_cap_bps":300}},
    {"id":"exec","kind":"execution","op":"market"}
  ],
  "edges": [
    {"from":"src_price","to":"i1","port":"price"},
    {"from":"i1","to":"c1","port":"x"},
    {"from":"c1","to":"cool","port":"want"},
    {"from":"cool","to":"decide","port":"gate"},
    {"from":"decide","to":"r1","port":"decision"},
    {"from":"i2","to":"r1","port":"vol"},
    {"from":"r1","to":"exec","port":"decision"}
  ],
  "output": "exec"
}
```

### Trend momentum basket

Trades both sides and is made for daily bars on a basket of markets. It goes long when the 30-bar rate of change
is above 0 and price is above its 100-bar SMA, and short in the mirror case; `decision.enter_long_short` turns the
position around when the other side fires. The stop is 3 × the 14-bar NATR, between 50 and 3000 bps.
`risk.fixed_risk` then sets a 100 USDT size and a 100000 bps target, out of reach, and `risk.risk_per_trade` sizes
each entry so that a stop-out costs 5 USDT, at most 100 USDT. A trade ends at the stop, on a turn to the other
side, or on the managed exit: a long is closed when the rate of change turns negative while price is still at or
above the SMA, and a short in the mirror case, through `state.position` and `decision.exit`. Orders are market
orders. It uses `decision.enter_long_short`, so importing a graph like it needs the Expert plan; starting from the
template does not.

```json
{
  "nodes": [
    {"id":"price","kind":"source","op":"candles"},
    {"id":"mom","kind":"indicator","op":"roc","params":{"period":30}},
    {"id":"up","kind":"rule","op":"gt","params":{"threshold":0}},
    {"id":"down","kind":"rule","op":"lt","params":{"threshold":0}},
    {"id":"trend","kind":"indicator","op":"sma","params":{"period":100}},
    {"id":"above","kind":"rule","op":"above"},
    {"id":"below","kind":"rule","op":"below"},
    {"id":"not_below","kind":"rule","op":"at_or_above"},
    {"id":"not_above","kind":"rule","op":"at_or_below"},
    {"id":"go_long","kind":"rule","op":"all"},
    {"id":"go_short","kind":"rule","op":"all"},
    {"id":"decide","kind":"decision","op":"enter_long_short","params":{"quote_usdt":100,"sl_bps":1000,"tp_bps":100000}},
    {"id":"natr","kind":"indicator","op":"natr","params":{"period":14}},
    {"id":"stops","kind":"risk","op":"dynamic_tp_sl","params":{"sl_mult":3.0,"rr":3,"min_sl_bps":50,"sl_cap_bps":3000}},
    {"id":"size","kind":"risk","op":"fixed_risk","params":{"quote_usdt":100,"tp_bps":100000}},
    {"id":"risk","kind":"risk","op":"risk_per_trade","params":{"risk_usdt":5,"max_quote_usdt":100}},
    {"id":"is_long","kind":"state","op":"position","params":{"field":"long"}},
    {"id":"is_short","kind":"state","op":"position","params":{"field":"short"}},
    {"id":"fade_long","kind":"rule","op":"all"},
    {"id":"fade_short","kind":"rule","op":"all"},
    {"id":"leave_long","kind":"rule","op":"all"},
    {"id":"leave_short","kind":"rule","op":"all"},
    {"id":"leave","kind":"rule","op":"any"},
    {"id":"out","kind":"decision","op":"exit"},
    {"id":"exec","kind":"execution","op":"market"}
  ],
  "edges": [
    {"from":"price","to":"mom","port":"price"},
    {"from":"mom","to":"up","port":"x"},
    {"from":"mom","to":"down","port":"x"},
    {"from":"price","to":"trend","port":"price"},
    {"from":"price","to":"above","port":"a"},
    {"from":"trend","to":"above","port":"b"},
    {"from":"price","to":"below","port":"a"},
    {"from":"trend","to":"below","port":"b"},
    {"from":"price","to":"not_below","port":"a"},
    {"from":"trend","to":"not_below","port":"b"},
    {"from":"price","to":"not_above","port":"a"},
    {"from":"trend","to":"not_above","port":"b"},
    {"from":"up","to":"go_long","port":"in0"},
    {"from":"above","to":"go_long","port":"in1"},
    {"from":"down","to":"go_short","port":"in0"},
    {"from":"below","to":"go_short","port":"in1"},
    {"from":"go_long","to":"decide","port":"long"},
    {"from":"go_short","to":"decide","port":"short"},
    {"from":"decide","to":"stops","port":"decision"},
    {"from":"natr","to":"stops","port":"vol"},
    {"from":"stops","to":"size","port":"decision"},
    {"from":"size","to":"risk","port":"decision"},
    {"from":"down","to":"fade_long","port":"in0"},
    {"from":"not_below","to":"fade_long","port":"in1"},
    {"from":"up","to":"fade_short","port":"in0"},
    {"from":"not_above","to":"fade_short","port":"in1"},
    {"from":"is_long","to":"leave_long","port":"in0"},
    {"from":"fade_long","to":"leave_long","port":"in1"},
    {"from":"is_short","to":"leave_short","port":"in0"},
    {"from":"fade_short","to":"leave_short","port":"in1"},
    {"from":"leave_long","to":"leave","port":"in0"},
    {"from":"leave_short","to":"leave","port":"in1"},
    {"from":"risk","to":"out","port":"decision"},
    {"from":"leave","to":"out","port":"gate"},
    {"from":"out","to":"exec","port":"decision"}
  ],
  "output": "exec"
}
```

### Basket rotation

Trades both sides and is made for daily bars on a basket that picks its own markets: `basket.universe` holds the 20
markets with the most USDT traded over the last 30 days, listed at least 60 days, and picks them again each quarter.
It reads nothing but its market's place in the basket. `source.basket_rank` ranks every market of the basket at each
bar by its 30-bar return over its volatility,
counted from the strongest (`from: top`) on one node and from the weakest (`from: bottom`) on the other. A market
among the 5 strongest is bought and one among the 5 weakest is sold short; a long is closed once the market is no
longer among the 10 strongest, a short once it is no longer among the 10 weakest. `risk.vol_target` sizes each entry
to a 40% yearly volatility on 100 USDT, at most 200 USDT, and the decision's 5000 bps stop is a catastrophe stop at
the exchange, not the exit. Orders are market orders. A graph that reads its rank has to be backtested and launched
on a basket; it also uses `decision.enter_long_short`, so importing a graph like it needs the Expert plan.
The research behind it found the rotation holds only on a basket picked again like this: on a fixed list of old large
markets it lost every year since 2024.

```json
{
  "nodes": [
    {"id":"top","kind":"source","op":"basket_rank","params":{"by":"return_vol","lookback":30,"skip":0,"from":"top"}},
    {"id":"bottom","kind":"source","op":"basket_rank","params":{"by":"return_vol","lookback":30,"skip":0,"from":"bottom"}},
    {"id":"go_long","kind":"rule","op":"le","params":{"threshold":5}},
    {"id":"go_short","kind":"rule","op":"le","params":{"threshold":5}},
    {"id":"is_long","kind":"state","op":"position","params":{"field":"long"}},
    {"id":"is_short","kind":"state","op":"position","params":{"field":"short"}},
    {"id":"long_faded","kind":"rule","op":"gt","params":{"threshold":10}},
    {"id":"drop_long","kind":"rule","op":"all"},
    {"id":"short_faded","kind":"rule","op":"gt","params":{"threshold":10}},
    {"id":"drop_short","kind":"rule","op":"all"},
    {"id":"decide","kind":"decision","op":"enter_long_short","params":{"quote_usdt":100,"sl_bps":5000,"tp_bps":100000}},
    {"id":"leave","kind":"rule","op":"any"},
    {"id":"size","kind":"risk","op":"vol_target","params":{"period":30,"target_vol_pct":40,"capital_usdt":100,"max_quote_usdt":200}},
    {"id":"out","kind":"decision","op":"exit"},
    {"id":"exec","kind":"execution","op":"market"},
    {"id":"universe","kind":"basket","op":"universe","params":{"by":"turnover","top":20,"window_days":30,"refresh":"quarter","min_age_days":60}}
  ],
  "edges": [
    {"from":"top","to":"go_long","port":"x"},
    {"from":"bottom","to":"go_short","port":"x"},
    {"from":"top","to":"long_faded","port":"x"},
    {"from":"is_long","to":"drop_long","port":"in0"},
    {"from":"long_faded","to":"drop_long","port":"in1"},
    {"from":"bottom","to":"short_faded","port":"x"},
    {"from":"is_short","to":"drop_short","port":"in0"},
    {"from":"short_faded","to":"drop_short","port":"in1"},
    {"from":"go_long","to":"decide","port":"long"},
    {"from":"go_short","to":"decide","port":"short"},
    {"from":"drop_long","to":"leave","port":"in0"},
    {"from":"drop_short","to":"leave","port":"in1"},
    {"from":"decide","to":"size","port":"decision"},
    {"from":"size","to":"out","port":"decision"},
    {"from":"leave","to":"out","port":"gate"},
    {"from":"out","to":"exec","port":"decision"}
  ],
  "output": "exec"
}
```

### Minute-top admissions

Launch this template as its own basket on **1m**, on Binance or Bybit. The server ranks eligible crypto perpetuals
by their last closed minute's change, separately for rises and falls. A fresh entry into the top 10 with at least
1% absolute change emits `source.screen_signal`: +1 for a rise, -1 for a fall, zero on ordinary candles. The graph
buys rises and sells falls at market, with a 50 bps stop and 100 bps target. Its requested risk is at most 1 USDT,
and its 100 USDT notional ceiling can reduce the actual risk below that. Leverage comes from the run's launch settings.

The first snapshot establishes a baseline and does not trade existing leaders. A market staying in the top does not
trigger again; the 15-minute cooldown covers both directions. Missing minutes and expired events are not replayed.
The existing liquidity, account, position and portfolio limits still apply. This template has no historical admission
backtest yet: start on paper and inspect actual fills and costs. Its initial settings are not measured trading results.

```json
{
  "nodes": [
    {"id":"admission","kind":"source","op":"screen_signal"},
    {"id":"rise","kind":"rule","op":"gt","params":{"threshold":0}},
    {"id":"fall","kind":"rule","op":"lt","params":{"threshold":0}},
    {"id":"entry","kind":"decision","op":"enter_long_short","params":{"obi_min":-1,"quote_usdt":100,"sl_bps":50,"tp_bps":100}},
    {"id":"size","kind":"risk","op":"risk_per_trade","params":{"risk_usdt":1,"max_quote_usdt":100}},
    {"id":"exec","kind":"execution","op":"market"},
    {"id":"markets","kind":"basket","op":"screen","params":{"rank_by":"change_1m","direction":"both","top":10,"min_change_pct":1,"cooldown_minutes":15,"min_volume_usdt":10000000,"min_range_pct":0,"min_natr_pct":0,"max_markets":20,"linger_minutes":0}},
    {"id":"portfolio","kind":"basket","op":"guard","params":{"max_positions":3,"max_drawdown_pct":10,"daily_loss_pct":5}}
  ],
  "edges": [
    {"from":"admission","to":"rise","port":"x"},
    {"from":"admission","to":"fall","port":"x"},
    {"from":"rise","to":"entry","port":"long"},
    {"from":"fall","to":"entry","port":"short"},
    {"from":"entry","to":"size","port":"decision"},
    {"from":"size","to":"exec","port":"decision"}
  ],
  "output": "exec"
}
```

## A prompt to start with

Copy this into a chat with the assistant, with this file attached, and replace the last line with your idea.

```text
You are helping me write a trading strategy for Metrand as a JSON strategy graph. The attached file, metrand-strategy-format.md, explains the format and lists every op Metrand's engine accepts.

- Use only the ops, ports and params in that file, by their own names, and write every param.
- Output only the complete graph, as one JSON object in a single code block.
- If my idea is unclear or cannot be built from those ops, ask me before you write anything.
- If the idea needs an op marked "Expert plan", ask me first whether I have the Expert plan.
- When I paste an error from Metrand, reply with the whole corrected graph.
- Do not tell me whether the strategy will make money: I will backtest it.

My idea: [the market, the timeframe, when to enter, when to exit, and how much to risk per trade]
```

## Op reference

Every op the engine accepts, by kind. "Hard bounds" are the limits the engine enforces; a value outside them is
an error. "Plans" says whether an imported graph with the op works on every plan or needs the Expert plan.

- **source**: `basket_rank`, `candles`, `funding`, `high`, `liquidations`, `low`, `open`, `open_interest`, `orderbook_imbalance`, `positioning`, `screen_signal`, `volume`
- **indicator**: `atr`, `bbpct`, `cci`, `cmo`, `dema`, `donchian`, `donchian_high`, `donchian_low`, `donchian_mid`, `ema`, `hma`, `hvol`, `linreg`, `macd`, `natr`, `obv`, `period_level`, `ppo`, `rma`, `roc`, `round_level`, `rsi`, `rvol`, `rvol_true`, `sma`, `stoch`, `stochrsi`, `swing`, `swing_beyond`, `tema`, `tsi`, `vwap`, `vwma`, `willr`, `wma`, `zscore`
- **transform**: `abs`, `add`, `candle`, `choose`, `clock`, `div`, `lag`, `level_distance`, `level_hold`, `level_mid`, `level_offset`, `level_pick`, `max`, `min`, `mul`, `neg`, `scale`, `sub`
- **rule**: `above`, `all`, `any`, `approx_eq`, `at_or_above`, `at_or_below`, `below`, `compare`, `cross_down`, `cross_up`, `false_break`, `ge`, `gt`, `in_range`, `le`, `level_between`, `level_cross`, `level_near`, `level_touch`, `lt`, `not`
- **state**: `cooldown`, `position`, `position_level`
- **model**: `logistic`, `threshold_score`
- **decision**: `enter_long`, `enter_long_short`, `enter_short`, `exit`, `grid`
- **risk**: `dynamic_tp_sl`, `edge_gate`, `fixed_risk`, `level_bracket`, `liquidity_cap`, `risk_per_trade`, `side_scale`, `vol_target`
- **execution**: `maker`, `market`, `reduce_only_close`, `stop_entry`
- **basket**: `guard`, `screen`, `universe`

### source

#### source.basket_rank

**Basket rank**. Where the market stands in its basket at this bar: 1 is the strongest by `by` counted from the top, or the weakest from the bottom. Needs a basket; markets without enough history are left out of the count.

Family: source · Emits: `float` · Plans: every plan

Also accepted as `rank`. Write `basket_rank`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `by` | enum |  | `return` | — | `return`, `return_vol`, `funding`, `turnover`, `turnover_change`, `volatility` | no | rank by return, return over its volatility, mean funding, quote turnover, the change of that turnover against the window before, or volatility |
| `lookback` | int | candles | 30 | 1 to 5000 |  | no | bars the score is measured over |
| `skip` | int | candles | 0 | 0 to 1000 |  | no | latest bars left out of the score |
| `from` | enum |  | `top` | — | `top`, `bottom` | no | count places from the strongest (top) or the weakest (bottom) |
| `scale` | enum |  | `rank` | — | `rank`, `fraction` | no | the place itself, or the place over the number of markets ranked |

#### source.candles

**Candles / price**. The symbol's price/OHLCV stream — the root feed most indicators read.

Family: source · Emits: `price` · Plans: every plan

Also accepted as `price`, `trades`. Write `candles`.

Inputs: none.

Params: none.

#### source.funding

**Funding rate**. The market's last funding settlement before the bar closes, in bps of notional: positive when longs pay shorts. A crowded long side pays a high rate.

Family: source · Emits: `float` · Plans: every plan

Inputs: none.

Params: none.

#### source.high

**Bar high**. The current bar's HIGH price.

Family: source · Emits: `float` · Plans: Expert plan

Inputs: none.

Params: none.

#### source.liquidations

**Liquidations**. The notional of the market's forced orders over the bar, in quote currency: longs closed, shorts closed, both, or longs less shorts. 0 on a bar without any.

Family: source · Emits: `float` · Plans: every plan

Also accepted as `liq`. Write `liquidations`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `side` | enum |  | `both` | — | `longs`, `shorts`, `both`, `net` | no | longs closed, shorts closed, both, or longs less shorts |

#### source.low

**Bar low**. The current bar's LOW price.

Family: source · Emits: `float` · Plans: Expert plan

Inputs: none.

Params: none.

#### source.open

**Bar open**. The current bar's OPEN price.

Family: source · Emits: `float` · Plans: Expert plan

Inputs: none.

Params: none.

#### source.open_interest

**Open interest**. The market's open interest at the last 5-minute step that ended five minutes or more before the bar's close, in quote notional or in contracts. Its change over a window (roc, zscore) shows positions being opened or closed.

Family: source · Emits: `float` · Plans: every plan

Also accepted as `oi`. Write `open_interest`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `unit` | enum |  | `usd` | — | `usd`, `contracts` | no | open interest in quote notional (usd) or in contracts |

#### source.orderbook_imbalance

**Order-book imbalance**. Top-of-book bid/ask imbalance in [-1,1] — microstructure confirmation.

Family: source · Emits: `obi` · Plans: every plan

Also accepted as `orderbook`, `obi`. Write `orderbook_imbalance`.

Inputs: none.

Params: none.

#### source.positioning

**Positioning**. Who is long at the last 5-minute step that ended five minutes or more before the bar's close: accounts long over accounts short (all, or the top traders'), the top traders' long positions over their short ones, or the takers' buy volume over their sell volume. Above 1, the long or buying side is larger.

Family: source · Emits: `float` · Plans: every plan

Also accepted as `long_short`. Write `positioning`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `field` | enum |  | `accounts` | — | `accounts`, `top_accounts`, `top_positions`, `takers` | no | all accounts, the top traders' accounts or positions, or the takers' buy/sell volume |

#### source.screen_signal

**Minute top: entry event**. A fresh server-authorized first entry into the minute top: +1 for a rise, -1 for a fall, 0 on normal bars. Connect through rules to the entry decision. Requires a minute-ranked basket.screen; no historical backtest.

Family: market · Emits: `float` · Plans: every plan

Inputs: none.

Params: none.

#### source.volume

**Bar volume**. The current bar's VOLUME.

Family: source · Emits: `float` · Plans: Expert plan

Also accepted as `vol`. Write `volume`.

Inputs: none.

Params: none.

### indicator

#### indicator.atr

**ATR**. Average True Range — absolute volatility from OHLC bars (Null on tick-only streams). With a step, the true range of blocks of that many bars: on 1-minute bars, step 5 is the ATR of 5-minute bars, moving every minute.

Family: bar · Emits: `float` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 14 | 1 to 5000 |  | no | ATR lookback, in steps |
| `step` | int | candles | 1 | 1 to 1440 |  | no | bars per step: the true range of blocks of this many bars |

#### indicator.bbpct

**Bollinger %B**. Position of price within its Bollinger band [0,1] — mean-reversion signal.

Family: volatility · Emits: `float` · Plans: every plan

Also accepted as `bb_pctb`, `bbands_pctb`, `percent_b`. Write `bbpct`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 2 to 5000 |  | no | band lookback |
| `k` | float | mult | 2 | 0.1 to 10 |  | no | std-dev band width |

#### indicator.cci

**CCI**. Commodity Channel Index from OHLC bars (Null on tick-only).

Family: bar · Emits: `float` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | lookback |

#### indicator.cmo

**CMO · Chande**. Chande Momentum Oscillator in [-100,100].

Family: momentum · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 14 | 1 to 5000 |  | no | momentum lookback |

#### indicator.dema

**DEMA**. Double exponential moving average (less lag than EMA).

Family: trend · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | series to average |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | lookback in candles |

#### indicator.donchian

**Donchian channel**. Rolling high/low/mid channel (bar) — breakout levels.

Family: bar · Emits: `float` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | channel lookback |
| `band` | enum |  | `upper` | — | `upper`, `lower`, `mid` | no | which channel line |

#### indicator.donchian_high

**Donchian High**. Rolling highest high (bar) — the upper breakout level. skip leaves the latest bars out (skip 1: the highest before this bar); recalc holds it from the start of each day, week or month. Drawn as a level.

Family: bar · Emits: `level` · Plans: every plan

Also accepted as `dc_upper`. Write `donchian_high`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | channel lookback |
| `skip` | int | candles | 0 | 0 to 1000 |  | no | latest bars left out (1: the extreme before this bar) |
| `recalc` | enum |  | `bar` | — | `bar`, `day`, `week`, `month` | no | when the value changes: every bar, or fixed at the start of each day, week or month (follow: when the reference level changes) |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### indicator.donchian_low

**Donchian Low**. Rolling lowest low (bar) — the lower breakout level. skip leaves the latest bars out (skip 1: the lowest before this bar); recalc holds it from the start of each day, week or month. Drawn as a level.

Family: bar · Emits: `level` · Plans: every plan

Also accepted as `dc_lower`. Write `donchian_low`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | channel lookback |
| `skip` | int | candles | 0 | 0 to 1000 |  | no | latest bars left out (1: the extreme before this bar) |
| `recalc` | enum |  | `bar` | — | `bar`, `day`, `week`, `month` | no | when the value changes: every bar, or fixed at the start of each day, week or month (follow: when the reference level changes) |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### indicator.donchian_mid

**Donchian Mid**. Midpoint of the Donchian channel (bar).

Family: bar · Emits: `float` · Plans: every plan

Also accepted as `dc_mid`. Write `donchian_mid`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | channel lookback |

#### indicator.ema

**EMA**. Exponential moving average of price.

Family: trend · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | series to average |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 5 | 1 to 5000 |  | no | lookback in candles (smaller = faster) |

#### indicator.hma

**HMA · Hull**. Hull moving average — fast and smooth.

Family: trend · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | series to average |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 16 | 2 to 5000 |  | no | lookback in candles |

#### indicator.hvol

**Historical Vol**. Historical (log-return) volatility over the window.

Family: volatility · Emits: `float` · Plans: every plan

Also accepted as `hist_vol`, `historical_volatility`. Write `hvol`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 2 to 5000 |  | no | return window |

#### indicator.linreg

**LinReg Slope**. Slope of the linear regression of price over the window (trend strength).

Family: statistical · Emits: `float` · Plans: every plan

Also accepted as `linreg_slope`, `lrs`. Write `linreg`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 2 to 5000 |  | no | regression window |

#### indicator.macd

**MACD histogram**. MACD histogram (fast EMA − slow EMA, minus signal EMA).

Family: momentum · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `fast` | int | candles | 12 | 1 to 2000 |  | no | fast EMA period |
| `slow` | int | candles | 26 | 1 to 4000 |  | no | slow EMA period |
| `signal` | int | candles | 9 | 1 to 2000 |  | no | signal EMA period |

#### indicator.natr

**NATR · bps**. Normalized ATR in basis points — volatility as a fraction of price. With a step, of blocks of that many bars, like the ATR.

Family: bar · Emits: `float` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 14 | 1 to 5000 |  | no | NATR lookback, in steps |
| `step` | int | candles | 1 | 1 to 1440 |  | no | bars per step: the true range of blocks of this many bars |

#### indicator.obv

**OBV**. On-Balance Volume — cumulative volume flow (needs volume; Null on tick-only).

Family: volume · Emits: `float` · Plans: every plan

Inputs: none.

Params: none.

#### indicator.period_level

**Period level (PDH, PDL, open)**. A price of a calendar period, UTC: the previous day's high or low (PDH, PDL), this week's open, the previous month's close. The previous period's value is fixed for the whole period from its own bars, so the first bar of a day never moves it; the current period's open is fixed at its first bar, its high and low move. A previous period with under half of its bars reads nothing.

Family: level · Emits: `level` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | enum |  | `day` | — | `day`, `week`, `month` | no | the calendar period: a day, a week from Monday, a month |
| `which` | enum |  | `previous` | — | `previous`, `current` | no | the period before this one, or this one so far |
| `field` | enum |  | `high` | — | `high`, `low`, `open`, `close`, `mid` | no | its high, low, open, close, or the middle of its range |
| `day_start_min` | int |  | 0 | 0 to 1439 |  | no | minutes after 00:00 UTC the day starts |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### indicator.ppo

**PPO**. Percentage Price Oscillator — MACD as a percentage (scale-free).

Family: momentum · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `fast` | int | candles | 12 | 1 to 2000 |  | no | fast EMA period |
| `slow` | int | candles | 26 | 1 to 4000 |  | no | slow EMA period |

#### indicator.rma

**RMA · Wilder**. Wilder's smoothed moving average (RMA/SMMA) of price.

Family: trend · Emits: `float` · Plans: every plan

Also accepted as `smma`, `wilder`. Write `rma`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | series to average |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 14 | 1 to 5000 |  | no | smoothing lookback |

#### indicator.roc

**ROC / Momentum**. Rate of change over `period` candles (percent move).

Family: momentum · Emits: `float` · Plans: every plan

Also accepted as `momentum`. Write `roc`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 10 | 1 to 5000 |  | no | lookback for the % change |

#### indicator.round_level

**Round number**. The nearest multiple of step above (or below) the close: 64,000 over BTC at 63,412. step 0 picks it from the price: 10^(digits of the price − digits), so 1,000 for BTC and 0.01 for a coin at 0.36.

Family: level · Emits: `level` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `side` | enum |  | `above` | — | `above`, `below` | no | the round number above the close, or below it |
| `nth` | int |  | 1 | 1 to 20 |  | no | 1 = the nearest, 2 = the one after it |
| `step` | float |  | 0 | 0 to 1000000000 |  | no | the price step; 0 = from the price |
| `digits` | int |  | 1 | 0 to 8 |  | no | with step 0: how many digits below the price's first the step sits |
| `recalc` | enum |  | `bar` | — | `bar`, `day`, `week`, `month` | no | when the value changes: every bar, or fixed at the start of each day, week or month (follow: when the reference level changes) |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### indicator.rsi

**RSI**. Relative Strength Index in [0,100].

Family: momentum · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 14 | 2 to 5000 |  | no | RSI lookback |

#### indicator.rvol

**StdDev**. Rolling standard deviation of price — dispersion.

Family: volatility · Emits: `float` · Plans: every plan

Also accepted as `stddev`, `vol`. Write `rvol`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 2 to 5000 |  | no | rolling window |

#### indicator.rvol_true

**Relative Volume**. Current volume vs its rolling average (needs volume).

Family: volume · Emits: `float` · Plans: every plan

Also accepted as `rel_volume`, `relative_volume`. Write `rvol_true`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | average window |

#### indicator.sma

**SMA**. Simple moving average of price.

Family: trend · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | series to average |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | lookback window in candles |

#### indicator.stoch

**Stochastic %K**. Stochastic %K from OHLC bars — position within the high/low range (Null on tick-only).

Family: bar · Emits: `float` · Plans: every plan

Also accepted as `stochastic`. Write `stoch`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 14 | 1 to 5000 |  | no | %K lookback |

#### indicator.stochrsi

**Stoch RSI**. Stochastic of RSI — a fast momentum oscillator in [0,100], unsmoothed.

Family: momentum · Emits: `float` · Plans: every plan

Also accepted as `stoch_rsi`. Write `stochrsi`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `rsi_period` | int | candles | 14 | 2 to 2000 |  | no | RSI lookback |
| `stoch_period` | int | candles | 14 | 1 to 2000 |  | no | stochastic window |

#### indicator.swing

**Swing pivot**. The latest confirmed swing high or low: a bar above (below) the left bars before it and at or above (below) the right bars after it. It is known only once the right bars have closed. nth 2 is the one before the latest.

Family: level · Emits: `level` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `side` | enum |  | `high` | — | `high`, `low` | no | swing highs or swing lows |
| `left` | int | candles | 4 | 1 to 100 |  | no | bars before the pivot it must stand beyond |
| `right` | int | candles | 4 | 1 to 100 |  | no | bars after the pivot that confirm it; it is known only once they have closed |
| `lookback_days` | int |  | 30 | 1 to 365 |  | no | days back a pivot may be |
| `unbroken` | enum |  | `no` | — | `no`, `yes` | no | only pivots no bar has closed beyond since they were confirmed |
| `nth` | int |  | 1 | 1 to 5 |  | no | 1 = the latest swing, 2 = the one before it |
| `recalc` | enum |  | `bar` | — | `bar`, `day`, `week`, `month` | no | when the value changes: every bar, or fixed at the start of each day, week or month (follow: when the reference level changes) |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### indicator.swing_beyond

**Swing beyond a level**. The most recent confirmed swing high above the wired level (a swing low below it), within lookback_days: MAX above yesterday's high. It is recomputed when the level changes, from the swings confirmed before that bar, and held until it changes again. pick closest takes the swing nearest in price; fallback extreme takes the lookback's highest high (lowest low) when no swing qualifies.

Family: level · Emits: `level` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `ref` | level | yes | the level the swing must lie beyond |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `side` | enum |  | `high` | — | `high`, `low` | no | swing highs or swing lows |
| `left` | int | candles | 4 | 1 to 100 |  | no | bars before the pivot it must stand beyond |
| `right` | int | candles | 4 | 1 to 100 |  | no | bars after the pivot that confirm it; it is known only once they have closed |
| `lookback_days` | int |  | 30 | 1 to 365 |  | no | days back a pivot may be |
| `unbroken` | enum |  | `no` | — | `no`, `yes` | no | only pivots no bar has closed beyond since they were confirmed |
| `pick` | enum |  | `latest` | — | `latest`, `closest` | no | the most recent swing beyond the level, or the one nearest it in price |
| `fallback` | enum |  | `none` | — | `none`, `extreme` | no | when no swing qualifies: nothing, or the lookback's highest high (lowest low) beyond the level |
| `recalc` | enum |  | `follow` | — | `follow`, `bar`, `day`, `week`, `month` | no | when the value changes: every bar, or fixed at the start of each day, week or month (follow: when the reference level changes) |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### indicator.tema

**TEMA**. Triple exponential moving average (even less lag).

Family: trend · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | series to average |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | lookback in candles |

#### indicator.tsi

**TSI**. True Strength Index — double-smoothed momentum.

Family: momentum · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `long` | int | candles | 25 | 1 to 4000 |  | no | long smoothing |
| `short` | int | candles | 13 | 1 to 2000 |  | no | short smoothing |

#### indicator.vwap

**VWAP · rolling**. Rolling volume-weighted average price (needs volume).

Family: volume · Emits: `float` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | rolling window |

#### indicator.vwma

**VWMA**. Volume-weighted moving average (needs volume).

Family: volume · Emits: `float` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | lookback window |

#### indicator.willr

**Williams %R**. Williams %R from OHLC bars in [-100,0] (Null on tick-only).

Family: bar · Emits: `float` · Plans: every plan

Also accepted as `williams_r`, `wpr`. Write `willr`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 14 | 1 to 5000 |  | no | lookback |

#### indicator.wma

**WMA**. Linearly-weighted moving average of price.

Family: trend · Emits: `float` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | series to average |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | lookback window in candles |

#### indicator.zscore

**Z-Score**. Standardized deviation of price from its rolling mean — mean-reversion.

Family: statistical · Emits: `float` · Plans: every plan

Also accepted as `zscore_price`. Write `zscore`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `price` | float | yes | price series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 2 to 5000 |  | no | rolling window |

### transform

#### transform.abs

**Absolute |a|**. Absolute value of a series.

Family: transform · Emits: `float` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | input |

Params: none.

#### transform.add

**Add (a + b)**. Sum of two wired series.

Family: transform · Emits: `float` · Plans: Expert plan

Also accepted as `sum`. Write `add`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left operand |
| `b` | float | yes | right operand |

Params: none.

#### transform.candle

**Candle shape**. One measure of a bar: its body (the distance from open to close), range, upper or lower wick (in price, or in ATRs with atr wired); the body's or a wick's share of the range (0…1); its colour (+1 green, −1 red, 0 doji); or its open, high, low, close. ago reads an earlier bar.

Family: level · Emits: `float` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `atr` | float | no | the ATR the body, range and wicks are divided by |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `field` | enum |  | `body` | — | `body`, `range`, `upper_wick`, `lower_wick`, `body_share`, `upper_share`, `lower_share`, `color`, `open`, `high`, `low`, `close` | no | what of the bar it measures |
| `ago` | int | candles | 0 | 0 to 20 |  | no | bars back the bar it reads is: 0 = this bar, 1 = the one before |

#### transform.choose

**Choose (if / else)**. One number or another by a condition: a (or then) while when is true, b (or else) while it is false. Turns a rule into a size, a weight or a threshold.

Family: transform · Emits: `float` · Plans: Expert plan

Also accepted as `if`, `select`. Write `choose`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `when` | bool | yes | condition |
| `a` | float | no | value while true (overrides then) |
| `b` | float | no | value while false (overrides else) |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `then` | float |  | 1 | -1000000000000 to 1000000000000 |  | no | value while the condition holds |
| `else` | float |  | 0 | -1000000000000 to 1000000000000 |  | no | value while it does not |

#### transform.clock

**Clock / time-of-day**. Emits a calendar field of the bar's timestamp — build session/time-of-day filters.

Family: transform · Emits: `float` · Plans: Expert plan

Also accepted as `time_of_day`. Write `clock`.

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `field` | enum |  | `minute_of_day` | — | `minute_of_day`, `hour`, `day_of_week` | no | which time field to emit |
| `tz_offset_min` | int |  | 0 | -1440 to 1440 |  | no | timezone offset in minutes from UTC |

#### transform.div

**Divide (a ÷ b)**. Ratio of two series (0 when b = 0).

Family: transform · Emits: `float` · Plans: Expert plan

Also accepted as `ratio`. Write `div`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | numerator |
| `b` | float | yes | denominator |

Params: none.

#### transform.lag

**Lag**. Delays a series by N bars (compare now vs earlier).

Family: transform · Emits: `float` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | float | yes | series to delay |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `n` | int | candles | 1 | 1 to 100000 |  | no | bars of delay |

#### transform.level_distance

**Distance to a level**. How far the close is from the level, signed (above it positive): (close − L) in ATRs of the wired atr, in % or in bps of the level.

Family: level · Emits: `float` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `level` | level | yes | the level |
| `atr` | float | no | the ATR, for a tolerance in ATRs |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `unit` | enum |  | `pct` | — | `atr`, `pct`, `bps` | no | ATRs of the wired atr, a percent or a basis point of the level |
| `ago` | int | candles | 0 | 0 to 20 |  | no | bars back the bar it reads is: 0 = this bar, 1 = the one before |

#### transform.level_hold

**Hold for the period**. Any series held as a level: at the first bar of each day (week, month) it takes the value its input had at the close before, and keeps it until the next one. An EMA «drawn in the morning».

Family: level · Emits: `level` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | float | yes | the series to hold |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `recalc` | enum |  | `day` | — | `day`, `week`, `month` | no | when the value changes: every bar, or fixed at the start of each day, week or month (follow: when the reference level changes) |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### transform.level_mid

**Between two levels**. The point f of the way from level a to level b: 0.5 is the midpoint.

Family: level · Emits: `level` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | level | yes | the level it starts from |
| `b` | level | yes | the level it goes to |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `f` | float |  | 0.5 | -10 to 10 |  | no | how far from a to b: 0 = a, 1 = b |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### transform.level_offset

**Level ± offset**. A level moved by k units: k × the wired ATR, k % or k bps of the level. A stop 0.2 ATR beyond a line is k −0.2 under a support.

Family: level · Emits: `level` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `level` | level | yes | the level to move |
| `atr` | float | no | the ATR, for unit atr |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `k` | float | mult | 1 | -1000 to 1000 |  | no | how many units, signed |
| `unit` | enum |  | `atr` | — | `atr`, `pct`, `bps` | no | the wired ATR, a percent or a basis point of the level |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### transform.level_pick

**Nearest level**. One of the wired levels l0…l7: the nth nearest above or below of (the price, an entry), the nth nearest to it, or the nearest to it between lo and hi. «Which line is just above the price», «the next line in the trade's direction».

Family: level · Emits: `level` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `l0` | level | yes | a level |
| `l1` | level | no | a level |
| `l2` | level | no | a level |
| `l3` | level | no | a level |
| `l4` | level | no | a level |
| `l5` | level | no | a level |
| `l6` | level | no | a level |
| `l7` | level | no | a level |
| `of` | float | no | the price the levels are measured from (needed for above, below, nearest) |
| `lo` | float | no | the zone's one edge (within) |
| `hi` | float | no | the zone's other edge (within) |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `mode` | enum |  | `above` | — | `above`, `below`, `within`, `nearest` | no | above or below of, nearest to of, or within lo…hi |
| `nth` | int |  | 1 | 1 to 8 |  | no | 1 = the nearest, 2 = the one after it |
| `strict` | enum |  | `yes` | — | `yes`, `no` | no | leave out a level exactly at of (or on a zone's edge) |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

#### transform.max

**Max(a, b)**. Element-wise maximum of two series.

Family: transform · Emits: `float` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | operand |
| `b` | float | yes | operand |

Params: none.

#### transform.min

**Min(a, b)**. Element-wise minimum of two series.

Family: transform · Emits: `float` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | operand |
| `b` | float | yes | operand |

Params: none.

#### transform.mul

**Multiply (a · b)**. Product of two series.

Family: transform · Emits: `float` · Plans: Expert plan

Also accepted as `product`. Write `mul`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left operand |
| `b` | float | yes | right operand |

Params: none.

#### transform.neg

**Negate (−a)**. Sign-flip a series.

Family: transform · Emits: `float` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | input |

Params: none.

#### transform.scale

**Scale (k·a + c)**. Affine transform of a series: multiply by k and add c.

Family: transform · Emits: `float` · Plans: Expert plan

Also accepted as `affine`, `normalize`. Write `scale`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | input |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `k` | float | mult | 1 | -1000000000 to 1000000000 |  | no | multiplier |
| `c` | float |  | 0 | -1000000000000 to 1000000000000 |  | no | offset added after scaling |

#### transform.sub

**Subtract (a − b)**. Difference of two series — e.g. a spread between two feeds.

Family: transform · Emits: `float` · Plans: Expert plan

Also accepted as `spread`, `diff`. Write `sub`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left operand |
| `b` | float | yes | right operand |

Params: none.

### rule

#### rule.above

**a above b**. True when series a is greater than series b.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `gt_dyn`. Write `above`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left series |
| `b` | float | yes | right series |

Params: none.

#### rule.all

**ALL (AND)**. True only when every wired condition is true.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `and`. Write `all`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `in0` | bool | yes | condition |
| `in1` | bool | no | condition |

Params: none.

#### rule.any

**ANY (OR)**. True when at least one wired condition is true.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `or`. Write `any`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `in0` | bool | yes | condition |
| `in1` | bool | no | condition |

Params: none.

#### rule.approx_eq

**a ≈ b**. True when two series are within a small tolerance of each other.

Family: rule · Emits: `bool` · Plans: Expert plan

Also accepted as `near`. Write `approx_eq`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left series |
| `b` | float | yes | right series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `eps` | float |  | 0.000000001 | 0 to 1000000000 |  | no | equality tolerance: true when \|a − b\| ≤ eps |

#### rule.at_or_above

**a ≥ b**. True when series a is at or above series b.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `ge_dyn`. Write `at_or_above`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left series |
| `b` | float | yes | right series |

Params: none.

#### rule.at_or_below

**a ≤ b**. True when series a is at or below series b.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `le_dyn`. Write `at_or_below`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left series |
| `b` | float | yes | right series |

Params: none.

#### rule.below

**a below b**. True when series a is less than series b.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `lt_dyn`. Write `below`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left series |
| `b` | float | yes | right series |

Params: none.

#### rule.compare

**Compare (a ⋛ b)**. Compare two series with a chosen operator, optionally by a margin: with eps, gt needs a > b + eps and lt needs a < b − eps.

Family: rule · Emits: `bool` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | float | yes | left series |
| `b` | float | yes | right series |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `op` | enum |  | `gt` | — | `gt`, `ge`, `lt`, `le` | no | comparison operator |
| `eps` | float |  | 0 | 0 to 1000000000 |  | no | margin a must clear b by |

#### rule.cross_down

**Crosses below**. True on the bar where `fast` crosses below `slow`.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `cross_under`. Write `cross_down`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `fast` | float | yes | faster series |
| `slow` | float | yes | slower series |

Params: none.

#### rule.cross_up

**Crosses above**. True on the bar where `fast` crosses above `slow`.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `cross_over`. Write `cross_up`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `fast` | float | yes | faster series |
| `slow` | float | yes | slower series |

Params: none.

#### rule.false_break

**False break**. The price broke the level and came back: for a resistance, within the last bars a high went above it by more than the tolerance and this bar closes below it; a support mirrored. from near: the close before those bars was on the level's near side.

Family: level · Emits: `bool` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `level` | level | yes | the level |
| `atr` | float | no | the ATR, for a tolerance in ATRs |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `side` | enum |  | `resistance` | — | `resistance`, `support` | no | a level above the price broken upward, or one below broken downward |
| `bars` | int | candles | 1 | 1 to 20 |  | no | bars back the wick may have gone through |
| `from` | enum |  | `any` | — | `any`, `near` | no | near: the price came to the level from its near side |
| `tol` | float | mult | 0 | 0 to 1000 |  | no | how close counts, in tol_unit |
| `tol_unit` | enum |  | `atr` | — | `atr`, `pct`, `bps` | no | ATRs of the wired atr, a percent or a basis point of the level |
| `ago` | int | candles | 0 | 0 to 20 |  | no | bars back the bar it reads is: 0 = this bar, 1 = the one before |

#### rule.ge

**≥ threshold**. True when the input is at or above a constant.

Family: rule · Emits: `bool` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | float | yes | value to test |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `threshold` | float |  | 0 | -1000000000000 to 1000000000000 |  | no | constant to compare against |

#### rule.gt

**Greater than**. True when the input exceeds a constant threshold.

Family: rule · Emits: `bool` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | float | yes | value to test |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `threshold` | float |  | 0 | -1000000000000 to 1000000000000 |  | no | constant to compare against |

#### rule.in_range

**In range [min, max]**. True when the input lies within a band — e.g. a neutral-regime filter.

Family: rule · Emits: `bool` · Plans: every plan

Also accepted as `between`. Write `in_range`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | float | yes | value to test |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `min` | float |  | 0 | -1000000000000 to 1000000000000 |  | no | lower bound (inclusive) |
| `max` | float |  | 100 | -1000000000000 to 1000000000000 |  | no | upper bound (inclusive) |

#### rule.le

**≤ threshold**. True when the input is at or below a constant.

Family: rule · Emits: `bool` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | float | yes | value to test |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `threshold` | float |  | 0 | -1000000000000 to 1000000000000 |  | no | constant to compare against |

#### rule.level_between

**Between two levels (zone)**. The close lies in the zone of levels a and b, in either order. False while either level is not known.

Family: level · Emits: `bool` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `a` | level | yes | one edge of the zone |
| `b` | level | yes | the other edge |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `inclusive` | enum |  | `yes` | — | `yes`, `no` | no | a close on an edge counts as inside |
| `ago` | int | candles | 0 | 0 to 20 |  | no | bars back the bar it reads is: 0 = this bar, 1 = the one before |

#### rule.level_cross

**Level cross**. The close crossed the level: up, the close before was at or below it and this one is above it by more than the tolerance (down mirrored). Both closes are measured against the level as it stands now, so a level that itself jumps across the price at the start of a day is not a cross.

Family: level · Emits: `bool` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `level` | level | yes | the level |
| `atr` | float | no | the ATR, for a tolerance in ATRs |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `dir` | enum |  | `up` | — | `up`, `down` | no | a cross up through the level, or down through it |
| `tol` | float | mult | 0 | 0 to 1000 |  | no | how close counts, in tol_unit |
| `tol_unit` | enum |  | `atr` | — | `atr`, `pct`, `bps` | no | ATRs of the wired atr, a percent or a basis point of the level |
| `ago` | int | candles | 0 | 0 to 20 |  | no | bars back the bar it reads is: 0 = this bar, 1 = the one before |

#### rule.level_near

**Near a level**. The close is within the tolerance of the level: the distance between them is at most tol. With tol 0, the close is at it.

Family: level · Emits: `bool` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `level` | level | yes | the level |
| `atr` | float | no | the ATR, for a tolerance in ATRs |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `tol` | float | mult | 0 | 0 to 1000 |  | no | how close counts, in tol_unit |
| `tol_unit` | enum |  | `atr` | — | `atr`, `pct`, `bps` | no | ATRs of the wired atr, a percent or a basis point of the level |
| `ago` | int | candles | 0 | 0 to 20 |  | no | bars back the bar it reads is: 0 = this bar, 1 = the one before |

#### rule.level_touch

**Level touch**. The bar's range reached the level, within the tolerance: low ≤ L + tol and high ≥ L − tol. from above: the close before was above it (the price came down to it); close above: the bar closed back above it. False while the level is not known.

Family: level · Emits: `bool` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `level` | level | yes | the level |
| `atr` | float | no | the ATR, for a tolerance in ATRs |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `tol` | float | mult | 0 | 0 to 1000 |  | no | how close counts, in tol_unit |
| `tol_unit` | enum |  | `atr` | — | `atr`, `pct`, `bps` | no | ATRs of the wired atr, a percent or a basis point of the level |
| `from` | enum |  | `any` | — | `any`, `above`, `below` | no | the side the close before the bar was on: the side the price came from |
| `close` | enum |  | `any` | — | `any`, `above`, `below` | no | the side the bar closed on |
| `ago` | int | candles | 0 | 0 to 20 |  | no | bars back the bar it reads is: 0 = this bar, 1 = the one before |

#### rule.lt

**< threshold**. True when the input is below a constant.

Family: rule · Emits: `bool` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | float | yes | value to test |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `threshold` | float |  | 0 | -1000000000000 to 1000000000000 |  | no | constant to compare against |

#### rule.not

**NOT**. Inverts a boolean condition.

Family: rule · Emits: `bool` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | bool | yes | condition to invert |

Params: none.

### state

#### state.cooldown

**Cooldown**. Suppresses re-entry for N bars after the gate last fired.

Family: state · Emits: `bool` · Plans: every plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `want` | bool | yes | raw entry wish |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `bars` | int | candles | 0 | 0 to 100000 |  | no | bars to wait between entries |

#### state.position

**Position field**. Surfaces a field of the strategy's own open position (for managed exits).

Family: state · Emits: `float` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `field` | enum |  | `in_position` | — | `in_position`, `flat`, `long`, `short`, `bars`, `upnl`, `entry`, `qty` | no | which position signal to read |

#### state.position_level

**Position level**. A price of the strategy's own open position: its entry, the stop-loss or take-profit the run holds, or its breakeven (the entry moved by the round trip's fees). Nothing while flat.

Family: level · Emits: `level` · Plans: Expert plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `field` | enum |  | `entry` | — | `entry`, `stop`, `take`, `breakeven` | no | the entry, the stop, the take or the breakeven |
| `fee_bps` | bps | bps | 10 | 0 to 1000 |  | no | round-trip fees the breakeven covers, bps |
| `label` | text |  | — | — |  | no | the line's name on the chart, up to 12 characters (empty: made from the params) |
| `role` | enum |  | `auto` | — | `auto`, `support`, `resistance`, `pivot`, `stop`, `target`, `entry`, `info`, `hidden` | no | how the line is drawn: support, resistance, pivot, stop, target, entry, info; hidden feeds others and is not drawn |
| `set` | text |  | — | — |  | no | the level set it belongs to (inserted together, toggled together) |

### model

#### model.logistic

**Logistic model (p_win)**. σ(bias + Σ wᵢ·featureᵢ) → a win probability for the edge gate. Fails closed if unscorable.

Family: model · Emits: `float` · Plans: Expert plan

Also accepted as `p_win`, `score`. Write `logistic`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `f0` | float | yes | feature 0 |
| `f1` | float | no | feature 1 |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `weights` | text |  | — | — |  | yes | per-feature weights (array, aligned to wired features) |
| `bias` | float |  | 0 | -1000000 to 1000000 |  | no | intercept term |

#### model.threshold_score

**Threshold score**. Weighted feature sum vs a threshold → a Bool gate. Fails closed if unscorable.

Family: model · Emits: `bool` · Plans: Expert plan

Also accepted as `threshold`. Write `threshold_score`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `f0` | float | yes | feature 0 |
| `f1` | float | no | feature 1 |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `weights` | text |  | — | — |  | yes | per-feature weights (array, aligned to wired features) |
| `threshold` | float |  | 0 | -1000000000 to 1000000000 |  | no | score cutoff for a true gate |

### decision

#### decision.enter_long

**Enter long**. When the gate fires (and OBI confirms), enter a long with an SL/TP bracket.

Family: decision · Emits: `decision` · Plans: every plan

Also accepted as `enter`, `enter_or_hold`. Write `enter_long`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `gate` | bool | yes | entry trigger |
| `obi` | float | no | order-book confirm |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `quote_usdt` | money | usdt | 25 | 1 to 1000000 |  | no | order size in quote currency |
| `obi_min` | float |  | -1 | -1 to 1 |  | no | min order-book imbalance to confirm (−1 disables) |
| `sl_bps` | bps | bps | 30 | 0.1 to 100000 |  | no | stop-loss distance in bps |
| `tp_bps` | bps | bps | 45 | 0.1 to 100000 |  | no | take-profit distance in bps |

#### decision.enter_long_short

**Enter long or short**. Both sides in one strategy: long when the long gate fires, short when the short gate does, nothing when both or neither do. An entry against the position held closes it and opens the other side at the same fill. A short's take-profit 100% or more below the entry is no take-profit.

Family: decision · Emits: `decision` · Plans: every plan

Also accepted as `long_short`. Write `enter_long_short`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `long` | bool | yes | long entry trigger |
| `short` | bool | yes | short entry trigger |
| `obi` | float | no | order-book confirm |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `quote_usdt` | money | usdt | 25 | 1 to 1000000 |  | no | order size in quote currency |
| `obi_min` | float |  | -1 | -1 to 1 |  | no | min imbalance on the entry's side to confirm (−1 disables) |
| `sl_bps` | bps | bps | 30 | 0.1 to 100000 |  | no | stop-loss distance in bps |
| `tp_bps` | bps | bps | 45 | 0.1 to 100000 |  | no | take-profit distance in bps |

#### decision.enter_short

**Enter short**. When the gate fires (and OBI confirms), enter a short with an SL/TP bracket.

Family: decision · Emits: `decision` · Plans: every plan

Also accepted as `short`. Write `enter_short`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `gate` | bool | yes | entry trigger |
| `obi` | float | no | order-book confirm |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `quote_usdt` | money | usdt | 25 | 1 to 1000000 |  | no | order size in quote currency |
| `obi_min` | float |  | -1 | -1 to 1 |  | no | min (sell-side) imbalance to confirm (−1 disables) |
| `sl_bps` | bps | bps | 30 | 0.1 to 100000 |  | no | stop-loss distance in bps |
| `tp_bps` | bps | bps | 45 | 0.1 to 100000 |  | no | take-profit distance in bps |

#### decision.exit

**Managed exit**. Overlay: when in-position and the gate fires, close the open position.

Family: decision · Emits: `decision` · Plans: every plan

Also accepted as `exit_signal`, `close`. Write `exit`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | the entry decision it overlays |
| `gate` | bool | yes | exit trigger |

Params: none.

#### decision.grid

**Grid / DCA ladder**. Multi-order: when the gate fires, rest N same-side post-only rungs at spacing steps off the touch (a long buy-grid below, a short sell-grid above). One-way-safe — a single-side ladder accumulates the position, never flips. total_usdt is split across rungs, each scale times the one before. first=market buys the first order at market and rests the rest 1, 2, … steps from it: a martingale.

Family: decision · Emits: `decision` · Plans: Expert plan

Also accepted as `dca`, `ladder`. Write `grid`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `gate` | bool | yes | requote trigger (e.g. a cooldown/clock) |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `levels` | int |  | 3 | 1 to 200 |  | no | number of ladder rungs |
| `spacing_bps` | bps | bps | 20 | 0.1 to 100000 |  | no | distance between rungs (bps off the touch) |
| `total_usdt` | money | usdt | 75 | 1 to 10000000 |  | no | TOTAL size across all rungs (quote currency) |
| `scale` | float |  | 1 | 0.1 to 10 |  | no | each rung's size as a multiple of the one before: 1 splits evenly, 2 doubles |
| `first` | enum |  | `maker` | — | `maker`, `market` | no | first order: rests like the others, or buys at market with the rungs hanging from it |
| `side` | enum |  | `long` | — | `long`, `short` | no | ladder direction: long buy-grid (below) or short sell-grid (above) |
| `sl_bps` | bps | bps | 30 | 0.1 to 100000 |  | no | protective stop distance per rung (bps) |
| `tp_bps` | bps | bps | 45 | 0.1 to 100000 |  | no | take-profit distance per rung (bps) |

### risk

#### risk.dynamic_tp_sl

**Volatility stops**. Set SL/TP from live volatility (NATR): SL = sl_mult·vol, TP = SL·rr.

Family: risk · Emits: `decision` · Plans: every plan

Also accepted as `vol_stops`. Write `dynamic_tp_sl`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |
| `vol` | float | no | volatility (e.g. NATR) |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `sl_mult` | float | mult | 1.5 | 0.1 to 50 |  | no | stop = sl_mult × volatility |
| `rr` | float | mult | 1.8 | 0.1 to 50 |  | no | reward:risk (tp = sl × rr) |
| `min_sl_bps` | bps | bps | 10 | 0.1 to 100000 |  | no | floor on the stop (bps) |
| `sl_cap_bps` | bps | bps | 300 | 0.1 to 100000 |  | no | cap on the stop (bps) |

#### risk.edge_gate

**Edge gate (EV)**. Veto entries whose expected value (from a model p_win) doesn't clear costs.

Family: risk · Emits: `decision` · Plans: Expert plan

Also accepted as `ev_gate`. Write `edge_gate`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |
| `p_win` | float | yes | model win probability |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `fee_bps` | bps | bps | 8 | 0 to 10000 |  | no | round-trip fee assumption (bps) |
| `min_ev_bps` | bps | bps | 0 | -100000 to 100000 |  | no | min expected value to allow (bps) |

#### risk.fixed_risk

**Fixed sizing**. Set a fixed order size and (optionally) override the SL/TP on the decision.

Family: risk · Emits: `decision` · Plans: every plan

Also accepted as `fixed`. Write `fixed_risk`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `quote_usdt` | money | usdt | 25 | 1 to 1000000 |  | no | order size in quote currency |
| `sl_bps` | bps | bps | — | 0.1 to 100000 |  | no | optional stop override (bps) |
| `tp_bps` | bps | bps | — | 0.1 to 100000 |  | no | optional target override (bps) |

#### risk.level_bracket

**Bracket at levels**. The stop-loss and take-profit at absolute prices from levels: the side's stop level moved beyond it by stop_buffer, its target level front-run by target_buffer (ATRs of atr, % or bps). A leg not wired keeps its bps. The risk engine blocks an entry whose stop is on the wrong side of its entry reference (the stop-entry trigger, or the touch), farther than max_stop_pct, or whose reward to risk is under min_rr or whose target is not beyond the entry.

Family: risk · Emits: `decision` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |
| `long_stop` | level | no | the level a long's stop goes beyond (below) |
| `long_target` | level | no | a long's target level |
| `short_stop` | level | no | the level a short's stop goes beyond (above) |
| `short_target` | level | no | a short's target level |
| `atr` | float | no | the ATR, for buffer_unit atr |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `stop_buffer` | float | mult | 0 | 0 to 1000 |  | no | how far beyond its level the stop goes, in buffer units |
| `target_buffer` | float | mult | 0 | 0 to 1000 |  | no | how far short of its level the target sits, in buffer units |
| `buffer_unit` | enum |  | `atr` | — | `atr`, `pct`, `bps` | no | ATRs of the wired atr, a percent or a basis point of the level |
| `min_rr` | float | mult | 0 | 0 to 100 |  | no | the least reward to risk an entry may have; 0 = off |
| `max_stop_pct` | percent | pct | 0 | 0 to 100 |  | no | the farthest the stop may be from the entry, %; 0 = off |

#### risk.liquidity_cap

**Liquidity cap**. Keep an order within share_pct % of what the market turns over in a bar (volume × close, averaged over period bars), so a thin market is never traded at a size its candles could not fill. Holds entries until period bars are in.

Family: risk · Emits: `decision` · Plans: every plan

Also accepted as `turnover_cap`. Write `liquidity_cap`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision, its size already set |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 20 | 1 to 5000 |  | no | bars the turnover is averaged over |
| `share_pct` | percent | pct | 1 | 0.001 to 100 |  | no | largest order as a share of a bar's turnover, % |

#### risk.risk_per_trade

**Risk per trade**. Size the position from its stop: a stop-out costs risk_usdt, so the order is risk_usdt ÷ stop distance, at most max_quote_usdt. Wire it after the node that sets the stop. With an absolute stop (a bracket at levels) the distance is from the entry's reference — the stop-entry trigger, or the touch — to the stop, sized by the risk engine once that reference is final.

Family: risk · Emits: `decision` · Plans: every plan

Also accepted as `risk_sizing`. Write `risk_per_trade`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision, its stop already set |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `risk_usdt` | money | usdt | 10 | 0.1 to 1000000 |  | no | what a stop-out costs, in quote currency |
| `max_quote_usdt` | money | usdt | 1000 | 1 to 10000000 |  | no | largest order it sizes, in quote currency |
| `cost_bps` | bps | bps | 0 | 0 to 1000 |  | no | fees and slippage added to the stop distance, bps of the entry, so the risk is what a stop-out costs after them |

#### risk.side_scale

**Size by side**. Size longs and shorts apart: a long entry's size times long_pct %, a short's times short_pct %, or times the long / short inputs when they are wired, so a market's trend can tilt the book bar by bar. A side at 0 % enters nothing.

Family: risk · Emits: `decision` · Plans: every plan

Also accepted as `side_weight`. Write `side_scale`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision, its size already set |
| `long` | float | no | long size in % (overrides long_pct) |
| `short` | float | no | short size in % (overrides short_pct) |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `long_pct` | percent | pct | 100 | 0 to 1000 |  | no | long entries' size, % of what the nodes before set |
| `short_pct` | percent | pct | 100 | 0 to 1000 |  | no | short entries' size, % of what the nodes before set |

#### risk.vol_target

**Volatility target**. Size to a volatility budget: order = capital × target ÷ the market's annualised volatility, at most max_quote_usdt. A calm market trades larger, a wild one smaller. Holds entries until period bars are in.

Family: risk · Emits: `decision` · Plans: every plan

Also accepted as `vol_sizing`. Write `vol_target`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `period` | int | candles | 30 | 1 to 5000 |  | no | bars the volatility is measured over |
| `target_vol_pct` | percent | pct | 40 | 0.5 to 1000 |  | no | annual volatility a position is sized to, % |
| `capital_usdt` | money | usdt | 1000 | 1 to 100000000 |  | no | capital the target applies to, in quote currency |
| `max_quote_usdt` | money | usdt | 1000 | 1 to 100000000 |  | no | largest order it sizes, in quote currency |

### execution

#### execution.maker

**Maker (post-only)**. Rest a post-only limit order (earns the maker rebate; may not fill).

Family: execution · Emits: `decision` · Plans: every plan

Also accepted as `limit`, `post_only`. Write `maker`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |

Params: none.

#### execution.market

**Market (taker)**. Cross the spread for an immediate taker fill.

Family: execution · Emits: `decision` · Plans: every plan

Also accepted as `taker`. Write `market`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |

Params: none.

#### execution.reduce_only_close

**Reduce-only close**. Reduce-only order that can only shrink/close the position.

Family: execution · Emits: `decision` · Plans: Expert plan

Also accepted as `close`. Write `reduce_only_close`.

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |

Params: none.

#### execution.stop_entry

**Stop-entry**. Enter with a stop-market order resting at a trigger price instead of at once: a long above the price at long_trigger (above candle 2's high), a short at short_trigger. It triggers on the last price, rests valid_bars bars and is cancelled at the close of the last, or sooner when the price reaches the cancel level (not wired: the stop-loss). When the price is already past the trigger, if_past skip leaves the entry and market buys at market within max_chase_bps (0: at any price).

Family: execution · Emits: `decision` · Plans: Expert plan

Inputs:

| Port | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | decision | yes | upstream decision |
| `long_trigger` | level | no | where a long's buy stop rests |
| `short_trigger` | level | no | where a short's sell stop rests |
| `long_cancel` | level | no | the price that cancels a long's stop-entry when reached first (default: the stop-loss) |
| `short_cancel` | level | no | the price that cancels a short's stop-entry when reached first |

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `offset_ticks` | int | ticks | 1 | 0 to 1000 |  | no | price steps the trigger goes beyond the level |
| `valid_bars` | int | candles | 1 | 1 to 20 |  | no | closed bars the order rests before it is cancelled |
| `if_past` | enum |  | `skip` | — | `skip`, `market` | no | when the price is already past the trigger: no entry, or enter at market |
| `max_chase_bps` | bps | bps | 10 | 0 to 10000 |  | no | with market: the farthest past the trigger it still enters, bps; 0 = any |
| `cancel_at_stop` | enum |  | `yes` | — | `yes`, `no` | no | the stop-loss reached before the trigger cancels the entry |

### basket

#### basket.guard

**Basket: stop**. The basket's own stop: when the whole basket falls max_drawdown_pct % from its peak, or loses daily_loss_pct % in a UTC day, every position is closed and the basket stops. max_positions caps how many positions its runs hold at once; a run enters only with a free place. 0 is off. Wired to nothing.

Family: basket · Emits: `—` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `max_drawdown_pct` | percent | pct | 0 | 0 to 100 |  | no | largest fall from the basket's peak, % of its capital (0 = off) |
| `daily_loss_pct` | percent | pct | 0 | 0 to 100 |  | no | largest loss in a UTC day, % of its capital (0 = off) |
| `max_positions` | int |  | 0 | 0 to 200 |  | no | most positions the basket's runs hold at once (0 = off) |

#### basket.screen

**Basket: markets on the move**. Pick markets every minute by turnover, range and NATR. rank_by change_1m ranks rises and falls of the last closed minute separately; screen_signal fires on entering that top. Existing positions remain managed after leaving the top. Paper and live. Wired to nothing.

Family: basket · Emits: `—` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `min_volume_usdt` | money | usdt | 10000000 | 0 to 1000000000000 |  | no | least quote turnover over the last 24 hours |
| `rank_by` | enum |  | `range_24h` | — | `range_24h`, `change_1m` | no | rank by daily range or the last closed minute |
| `direction` | enum |  | `both` | — | `both`, `long`, `short` | no | minute top: rises, falls, or both ranked separately |
| `top` | int |  | 10 | 1 to 200 |  | no | minute top: number of markets per direction |
| `min_change_pct` | percent | pct | 1 | 0.01 to 1000 |  | no | minute top: minimum absolute percentage change |
| `cooldown_minutes` | int |  | 15 | 0 to 1440 |  | no | minute top: time between entry events for one market |
| `min_range_pct` | percent | pct | 6 | 0 to 1000 |  | no | least 24-hour range: its high over its low, less one, in % |
| `min_natr_pct` | percent | pct | 0 | 0 to 100 |  | no | least NATR on 5-minute bars, in % (0 = off) |
| `max_markets` | int |  | 60 | 2 to 200 |  | no | most markets the basket holds at once |
| `linger_minutes` | int |  | 120 | 0 to 1440 |  | no | minutes a market that left the screen is kept |
| `include` | text |  | — | — |  | no | markets always in the basket while they trade, e.g. BTCUSDT, ETHUSDT |
| `exclude` | text |  | — | — |  | no | markets never in the basket |

#### basket.universe

**Basket: markets by rule**. Which markets the basket holds: the top ones by turnover, its change, volatility or return over a window of days, picked again every day, week, month or quarter. Markets that leave are closed, markets that enter are traded. Wired to nothing.

Family: basket · Emits: `—` · Plans: every plan

Inputs: none.

Params:

| Key | Type | Unit | Default | Hard bounds | Choices | Required | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `by` | enum |  | `turnover` | — | `turnover`, `turnover_change`, `volatility`, `return` | no | pick the markets by quote turnover, its change against the window before, volatility, or return |
| `top` | int |  | 20 | 2 to 200 |  | no | how many markets the basket holds |
| `window_days` | int |  | 30 | 1 to 365 |  | no | days the markets are measured over |
| `refresh` | enum |  | `quarter` | — | `day`, `week`, `month`, `quarter` | no | how often the markets are picked again (UTC calendar starts) |
| `min_age_days` | int |  | 60 | 0 to 3650 |  | no | days a market has been listed before it can be picked |
| `min_turnover_usdt` | money | usdt | 0 | 0 to 1000000000000 |  | no | least average daily turnover over the window |
| `include` | text |  | — | — |  | no | markets always in the basket, e.g. BTCUSDT, ETHUSDT |
| `exclude` | text |  | — | — |  | no | markets never in the basket |
