Skip to content

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.

Where: the Bots dashboardLanguage: LuaRuns on: closed bars (time, tick, or volume series)
The Bots dashboard with a running bot's journal, activity feed, and closed positions
The Bots dashboard with a running bot's journal, activity feed, and closed positions

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 script
if crossover(fast, slow) then
bot.buy{ qty = 0.01, limit = close * 0.999, stop = close * 0.99, tif = "post" }
end

bot.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.

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.

  • 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.

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.