A backtest tells you how rules behaved on the past. It can't tell you about the bug you haven't found, the data feed that sends one bad price, or the market that does something it never did before. That's why an algorithm trading real money should run inside limits that don't depend on the algorithm being right. On MarketsCoder every live and paper deployment has three, checked outside your code, before any order reaches the broker.
1. Largest order value
The most a single order may be worth, in the account's currency. It catches the classic mistakes: a quantity in shares where you meant dollars, a position-sizing formula that divides by something near zero, an extra zero. Set it a little above the largest order your strategy should ever place. If it sizes positions at 10% of a $20,000 account, a limit around $2,500 leaves room for normal moves and stops anything wild.
2. Orders per minute
A ceiling on how fast the algorithm can trade. A strategy that rebalances daily places a handful of orders a day; if it suddenly sends hundreds a minute, something is looping. The limit turns a runaway loop into a few refused orders instead of a pile of fills and fees. The default is 30 a minute; a slow strategy can use far less.
3. The drawdown stop
The largest fall from the account's peak equity you'll accept, as a percentage. The platform checks the account's equity every 30 seconds. Once it has fallen by the limit, trading stops for good: open orders are canceled and the algorithm is stopped. Positions are left as they are, because closing them automatically in a fast market could be the worst moment to do it; you decide what to do next.
To choose it, look at the strategy's backtest. If its worst drawdown was 12%, a stop at 18 to 20% gives it room to have a bad stretch like the ones it survived, while catching a strategy that has stopped working. A stop tighter than the backtest's own drawdown will fire on normal behaviour.
What happens when a limit is hit
- Order value or rate: the order is refused before it reaches the broker and logged, and your algorithm gets an error it can handle, for example by sizing down.
- Drawdown: trading stops for that deployment, as above, and the deployment shows why.
The monitoring agent can watch the same deployment and email you when it's getting close to a limit, before it's hit.
Limits for AI agents
Agents that can trade work under the same checks. A custom agent also has its own per-order limit, a most orders per run, an optional list of symbols it may trade, and can be set to ask for your approval before each order.
Before you go live
- Run the strategy with its limits on a paper account first, and check no normal order is refused.
- Give the broker key trade permissions only, never withdrawals. Our broker guide shows how for each broker.
- Start with less money than the strategy is designed for, and raise it as live results match the test.
Frequently asked questions
What risk limits should a trading bot have?
At least three: a largest order value, so one bad order can't be huge; a most orders per minute, so a loop can't flood the broker; and a drawdown stop, which stops trading after a set fall from the account's peak.
What happens when an order breaks a limit on MarketsCoder?
It's refused before it reaches the broker, logged, and the algorithm gets an error it can handle. Nothing is sent.
What does the drawdown stop do?
Once the account falls by the set percentage from its peak, trading stops for good: open orders are canceled and the algorithm is stopped. Positions are left as they are, for you to decide.
