Home Security & Best Practices Understanding the dry_run safety model

Understanding the dry_run safety model

Last updated on Jul 22, 2026

If you're going to let an AI touch a trading account, you should understand exactly what stops it from doing something you didn't intend. MTContext's answer is the dry_run model, and it's worth understanding in detail. This article goes a level deeper than Placing trades safely with dry_run.

Every trade-affecting tool defaults to a dry run

It isn't just the "place order" tool. Every tool that can change your account — place_order, close_position, modify_position, modify_order, cancel_order, and partial_close — defaults to dry_run: true. A dry run validates the request and reports exactly what would happen, but sends nothing to your broker. Real execution only occurs when a request explicitly carries dry_run: false. There is no "default to live" anywhere in the system.

Two independent gates, not one

For a live order to actually reach your broker, two separate conditions both have to be true:

  1. The request must explicitly set dry_run: false, and
  2. The Expert Advisor on your terminal must have trading enabled (inp_AllowTrading = true).

These are independent on purpose. Even if a request were made with dry_run: false, an EA that isn't set to allow trading won't execute it. You can run the EA in a read-and-validate-only mode and know that nothing can trade, regardless of what any client asks.

There's also a capability gate above both: trading tools require the trade capability (Pro tier and up). On the free tier the trade tools aren't available at all.

What a dry run validates before you ever go live

When you do confirm a real trade, it's still checked first and fails safe if anything is off:

  • Lot size against your broker's minimum, maximum, and step.
  • Margin against what's actually available in your account.
  • Broker rules — symbol availability, trading hours, restrictions — which MTContext can validate against but never override.

If a check fails, the order is rejected rather than sent.

Commands can't fire twice

Each command carries a unique identifier and is de-duplicated. If a request is retried — a flaky connection, an over-eager client — the same order won't accidentally execute twice.

The account-level backstop

Individual trades are one layer; your whole account is another. The server-side equity guard can close positions or block new trades if your equity falls past a limit you set, and it runs independently of whether your AI client is connected. See Setting up equity protection guardrails.

The bottom line

Nothing trades unless you explicitly pass dry_run: false, the EA is set to allow trading, and your broker accepts the order. Three things have to line up, and each one is under your control or your broker's.

Next steps

See Placing trades safely with dry_run for the everyday version, and What MTContext can and can't do for the full capability boundary.

Explore it free at mtcontext.com — the free tier is read-only, so trading tools are off entirely.