Trading bots
Trading bots run a Lua script - the same language as
custom indicators - on every closed bar of a
configured market, and turn its bot.buy / bot.sell calls into real orders on the venue
you point them at. Each bot keeps its own journal (position, PnL, activity log) and runs
inside hard guardrails.

How a bot runs
Section titled “How a bot runs”A bot binds a script to a venue + symbol + series (a timeframe like 5m, or a
tick/volume bar series). On every closed bar the script runs with live context - current
position, allocation, account equity - and may emit actions:
-- inside your bot scriptif crossover(fast, slow) then bot.buy{ qty = 0.01, limit = close * 0.999, stop = close * 0.99, tif = "post" }endbot.buy{...} / bot.sell{...} accept qty (required), limit, trigger (stop entries;
both together = stop-limit), protective stop / target, and
tif = "gtc" | "ioc" | "fok" | "post" (time-in-force).
Invalid arguments error the action loudly rather than sending a malformed order.
Journals and attribution
Section titled “Journals and attribution”The venue doesn’t know which orders are a bot’s - the journal does. Each bot records the orders it placed, its own net position and average price, realized PnL, win/loss counts, and completed round trips (the closed positions table). The activity feed logs fills, rejections with the venue’s reason, and guardrail events - and can be copied out with one click.
Guardrails
Section titled “Guardrails”- Allocation - a bot can’t commit more than its configured share.
- Daily-loss halt - each bot baselines its venue’s account equity at the start of the day (the day rolls at midnight of your configured display time zone); if realized plus marked unrealized loss crosses the configured percentage, the bot halts.
- Orphan protection - an order that never got a venue id (a crash mid-placement) halts the bot for a human look instead of guessing.
Where bots can trade
Section titled “Where bots can trade”Bots run per-venue and size against that venue’s account equity - paper, live venues, and the Replay venue. On Replay, a session restart (rewind / new range / new balance) stops running replay bots with a toast: the market they were trading no longer exists.
Related
Section titled “Related”- Custom indicators (Lua) - the scripting language and
ta.*library. - Market replay - a repeatable market to test against.
- Time-in-force - the
tifargument’s semantics.