algo
An algo: a script that trades an account through the fixed order types (order.*). Must be the first
statement, in place of indicator(). It runs as orders when every order.* call sits in algo.onArm:
arming runs that function once and places the orders it makes, fixed numbers that the tab or 0xArchive’s
server runs. An order call anywhere else is live logic (later).
void
Runs once when the trader arms the algo, after setup and history: the orders it makes are what arming places.
The sentence the algo’s settings lead with (“Chase buy $1,000, never past 61,290”).
(o?: { shots?: number; expires?: Duration; sides?: 'long' | 'short' | 'both'; cooldown?: Duration }): void
A strategy’s arm (
lifetime: 'standing'): how many trades it may take, until when, on which sides, and the wait
after each. From a button’s onPress, or at the top level to arm it from the start (full auto, shots: Infinity).((o?: { owner?: 'trader' | 'code'; initial?: 'long' | 'short' | 'both' | 'off' }) => void) & { /** The script's bias, when it owns it. The trader's Off still wins. */ set(dir: 'long' | 'short' | 'both' | 'off'): void; }
Who sets the direction allowed: the trader (the strip’s Long, Short, Both, Off) or the script, with
algo.bias.set. Top level.The day’s limits, from the account’s real fills (manual trades count): a breach halts entries. Top level. Every strategy has one.
Where the strategy may engage: a trigger outside every zone for its side is journaled, not traded.
The moment the strategy would trade. The tab trades it when armed, the bias allows its side, its price is in a
zone (when there are zones), and the governor has room; otherwise it is journaled as “would have traded”. Live
events only: whether it was sent.
(fn: (trigger: { side: 'long' | 'short'; price: number; why: string; strength: number | null }) => StrategyPlan): void
The trade a trigger makes, in trader terms. The stop goes in before the entry, the targets once it fills. Top level.
AlgoOptions
An algo’s display options are an indicator’s; it runs on a market, never in a panel.What its orders do to risk:
'protect' may only reduce a position, 'entry' may add. Default 'entry'.'once' (the default) ends when its orders have; 'standing' stays armed and runs as a script (later).What it may trade, shown when it is armed: the chart’s market or a list, and a cap on the position.
Side
OrderSize
An order’s size.pctOfPosition sizes an exit; riskUsd is the size that loses that much if stop is hit.
Duration
Seconds, or text such as'30s', '5m', '4h', '2d'.
OrderRef
An order an algo made. In a plan it reads'planned'. Armed, a call on a live event reads 'sent': a request the
tab admits or refuses, whose answer and fills arrive on account().onOrder and onFill, by tag. In history, or
before the algo is armed, it reads 'none': nothing was sent.
Leg
A resting order: an OCO’s leg, or a limit.Trigger
A test of one of the execution service’s own prices, fororder.when. Made by trigger.*.
TriggerTest
TriggerOptions
control
A strategy’s controls: how the trader drives it now. Declared at the top level, at most 16. A change is an event, never a re-run. In history a control reads itshistory value, and a button never fires.
A price the trader types or drags. Empty in history: a level set today gets no credit for last month.
StrategyPlan
A trade in trader terms.r targets count from the entry to the stop.
order
The order types an algo places. Each call is one order of that type, checked against its ranges at arm.(o: { side: Side; size: OrderSize; limitPx?: number | null; peg?: 'touch' | 'inside'; maxReprices?: number; maxTime?: Duration; onEnd?: 'cancel' | 'cross'; reduceOnly?: boolean; tag?: string }): OrderRef
Rest at the best price and follow it until filled, never past
limitPx. maxTime gives up; onEnd: 'cross' takes the rest.(o: { px: number | null; source?: 'mark' | 'book' | 'trade'; size?: OrderSize; confirm?: Duration; bandPct?: number; attempts?: number; tag?: string }): OrderRef
Close the position held at arm (or
size of it) when the price reaches px: the mark, the best bid or ask
('book'), or the last trade. Watched by the runner, not resting on the venue. Exits in reduce-only rounds
within bandPct of the mark, at most attempts times.(o: { after?: Duration; at?: number; size?: OrderSize; bandPct?: number; attempts?: number; tag?: string }): OrderRef
Close the position held at arm (or
size of it) after a hold, or at a time.Two resting orders: the first to fill cancels the other.
When the trigger’s test holds, make the one order
then makes: order.reduce, order.close, order.limit or order.market.A reduce-only order at market within the band, as a condition’s action.
Close the whole position at market within the band, as a condition’s action.
(o: { side: Side; size: OrderSize; bandPct?: number; reduceOnly?: boolean; tag?: string }): OrderRef
An order at market within the band, as a condition’s action.
Live logic: cancel the working orders made with this tag (or this ref’s tag). Not in
algo.onArm.(o: { bidPx: number | null; askPx: number | null; size: { usd: number } | { coins: number }; tag?: string }): OrderRef
Live logic: quote both sides. A post-only bid at
bidPx and ask at askPx, each of size, rest in the account;
each call moves them (a moved quote goes to the back of its new level), and null pulls that side. The host keeps
the position inside algo({ trades: { maxPositionUsd } }): the side that would pass it is pulled. Quoting runs on the Paper account.Not available: use the ticket’s TP/SL, or
order.fastStop with order.when.Not available.
trigger
The pricesorder.when can test, as the execution service reads them. A null value (an empty price input) is refused at arm.
The funding rate per hour, as a fraction.
account()
The account the algo trades. Declared at the top level, once.OrderEvent
What became of one of an algo’s orders: the tab’s answer to it, or a change in what it placed.'refused' with code (needs_stop, shots_used, entry_rate_limited, …) and words when the tab did not place it.AlgoAccount
The account the algo trades. Inalgo.onArm, as it stands at the arm. Armed, as the tab last read it, for live
logic. Otherwise it reads flat.
{ readonly side: 'long' | 'short' | 'flat'; readonly size: number; readonly entryPrice: number; readonly notionalUsd: number }
The position in the algo’s market:
size in coins, entryPrice the average entry.Each answer and change to the algo’s orders, on live events only, never in history. Registered at the top level.
When one of the algo’s orders fills more. Registered at the top level.