Prop Firm EA Development: Building MT5 Bots That Survive FTMO-Style Rules
A profitable EA is not a passing EA. The rules that decide your challenge — daily loss, max drawdown, consistency, news windows — are code requirements, and the firm's dashboard tells you about a breach after it has already cost you the account. This guide covers the guardrail layer that makes the bot stop itself first. It is the checklist we build against when clients hire MQL4/MQL5 developers for prop-firm systems.
Table of Contents
Prop Firm Rules Are Code Requirements
FTMO-style challenges are a rule set: a daily loss limit (typically 5%), a maximum total drawdown (typically 10%), a minimum number of trading days, and consistency constraints on position sizing or trade counts. The trader who reads these as "risk guidelines" loses the account on a volatility spike. The developer who reads them as code requirements builds an EA that cannot breach them.
The dashboard is the wrong safety net. It computes your drawdown after the fact, from broker data, and it exists to terminate accounts — not to warn them. By the time it shows a breach, the breach already happened. Self-enforcement means the EA computes the same numbers the firm computes and acts before the breaching order is ever placed.
The Guardrail Layer
The guardrail layer sits in front of the signal logic. On every tick it evaluates the account's current state against the firm's limits, and only if everything passes does the signal engine get to run.
- Daily loss monitor. The EA snapshots equity at the start of the trading day (server midnight, not broker-local midnight — the firm's clock is what counts) and compares live equity against it. Loss over the internal limit: no new entries, and optionally a controlled flatten.
- Max-DD circuit breaker. Tracked from the equity high-water mark rather than the day boundary, because the firm's total drawdown does not reset at midnight. Both limits can be active simultaneously — that is the realistic case.
- Trade-count and lot caps. Consistency and minimum-trading-day rules cut both ways: the EA must trade enough to count a day but never more than the firm's density limits. Caps on trades per day and lot size per trade make both enforceable.
- Restart survival. Every limit's state — the day's snapshot, the high-water mark, the running counters — is persisted, not held in memory. A platform restart at 3 AM must not reset the daily loss clock, because the firm's clock does not reset either.
These guards are the same ones embedded in our builder-generated EAs and in every custom build — the layering is described in the MQL5 EA architecture guide.
The News Filter
High-impact releases are the most common account killer, and not because the trade loses — because the spread widens 10 to 40 pips in seconds, stops slip, and a 1% planned loss becomes a 4% realized one on the same day the firm's trailing drawdown tightens. The news filter blocks new entries inside a blackout window around scheduled high-impact events.
- Calendar integration. The EA pulls a high-impact event list — from an external calendar feed or a compiled schedule — with each event's server time.
- Server time versus GMT offsets. This is the classic bug. The firm's clock, the broker's server clock and the calendar's GMT stamps are three different time zones. Every conversion happens once, in one function, with a configurable offset — never scattered through the code.
- Blackout windows. Configurable minutes before and after each event; entries blocked, pending orders optionally pulled, and a settle-down delay after the window before normal trading resumes.
- Fallback behavior. If the calendar feed is down, the EA fails closed — no news data means no new entries during uncertain windows, with a logged warning. Failing open turns a feed outage into an account breach. We maintain a ready-made implementation in the news blackout timer guideline.
Spread and Slippage Guards
Before every entry, the EA reads SYMBOL_SPREAD and compares it against a configured maximum. Spread over threshold: no order. This single check converts news-driven spread spikes from account-ending entries into skipped signals.
The second guard handles what the first cannot: rejection. When a fill is rejected — requote, off-quotes, busy server — the EA retries with a bounded count and a timeout, then abandons the signal and logs the event. Unbounded retry loops turn a 2-second spread spike into a position opened at the worst price. And on gold specifically, the spread guard must be configured wider than on forex: XAUUSD routinely sits at 20 to 35 points of spread at a retail broker and can spike past 200 during news, so a "max spread" tuned for EURUSD is meaningless on a gold bot.
Backtest Reality Check
A prop-firm EA gets one acceptance test, and it is the challenge. The backtest has to predict the challenge, so the backtest has to model the challenge's reality:
- Tick data over broker data. Real tick history with the actual spread at the moment of each trade. A fixed-spread backtest is fiction, and on news days it is optimistic fiction — the exact days that decide challenges.
- Floating spreads modeled. The MT5 tester's floating spread setting, or real-spread tick data, so the EA's own spread guard actually fires during the test instead of being invisible.
- Realistic swap. Grid and carry strategies live or die on swap. Test with the broker's actual swap rates, not zero.
- The ten-year curve is a warning, not a trophy. A decade of flat profit factor with three surviving drawdown spikes tells you more than a beautiful two-year curve. The walk-forward discipline behind honest evaluation is covered in MQL5 optimization mastery.
Case Study: Hardening a Gold Bot
Gold is the hardest symbol for prop-firm EAs: deep news reactions, wide and unstable spreads, and overnight swap. Two of our free robots — the XAU RSI Grid MT5 and the UT Bot Gold Scalper MT5 — shipped with their core strategies intact, and the prop-firm hardening added three layers on top: a daily-loss guard, a news blackout, and a spread filter. The measured difference across three hostile scenarios:
| Scenario | Unprotected Result | Guarded Result |
|---|---|---|
| NFP day | Three grid levels opened into a 40-pip spread spike; -4.2% intraday drawdown | News blackout blocked all entries; flat on the day |
| Drawdown spike | Floating drawdown hit -8.7% mid-grid; firm daily limit breached | Daily-loss guard halted at -4.9%; account survived the session |
| Spread blowout | Scalper entries filled at 40+ pip spreads; 12-pip stops slipped to -3.1R | Spread filter rejected every fill above threshold; zero slippage trades |
The strategy and entry engine did not change. What changed is that the EA now declines the trades that would end the account — exactly the behavior a prop firm looks for before it funds you.
The Prop-Firm Readiness Checklist
Twelve guards, each mapped to the rule it protects. If an EA you are evaluating is missing any of these, the challenge is carrying risk the strategy does not have to.
| Guard | Why |
|---|---|
| Daily loss limit | Enforces the firm's 4-5% daily rule from equity, before the dashboard does |
| Max-DD circuit breaker | High-water-mark tracking matches the firm's total drawdown math |
| Trade-count cap | Satisfies minimum trading days without density violations |
| Lot cap | Keeps position sizing inside consistency rules |
| News blackout | Blocks entries in restricted or spread-hostile event windows |
| Spread filter | Rejects entries when the fill price would start the trade deep underwater |
| Session filter | Trades liquid hours where spreads and slippage are normal |
| New-bar filter | One decision per bar — no duplicate signals on the same setup |
| Stop on every position | Hard stops satisfy firms that flag naked positions as gambling behavior |
| Equity-based sizing | Percent-risk lots shrink after losses, protecting the drawdown budget |
| Restart persistence | Limit state survives platform restarts, like the firm's clock |
| Breach notification | Alert on internal breach or desync instead of silent shutdown |
Frequently Asked Questions
What rules must a prop firm EA enforce?
Daily loss limit, maximum drawdown, minimum trading days, and consistency limits such as lot or trade-count caps. The EA must enforce these internally from equity data, because the firm's dashboard reports breaches after they happen — a bot that stops itself at 4.5% protects a 5% daily limit.
How do you add a daily loss limit to an EA?
Snapshot the account equity and the day's start time at the beginning of each trading day, persist both so they survive restarts, then on every tick compare current equity against the snapshot. If the loss exceeds the configured limit, block all new entries and optionally close open positions. The comparison must run before the signal logic, not after.
Do prop firms allow EAs?
Most firms allow EAs, including FTMO, Apex and Topstep. What firms restrict is behavior: some ban trading during high-impact news windows, some review high-frequency strategies, and nearly all prohibit practices like arbitrage across accounts. An EA that self-enforces the firm's rules is treated as normal automation; an EA that breaches them ends the challenge regardless of profit.
How do I test a prop firm EA before a challenge?
Run the exact rules in the tester first: real tick data with floating spreads, realistic swap settings, and the firm's daily loss and drawdown limits configured as EA parameters. Then run a forward demo with the same settings for at least two weeks, including a high-impact news week. The strategy tester proves the logic; the forward demo proves the guards survive a live feed.
What is the most common reason prop firm EAs fail?
Not drawdown of the strategy itself — breach of a rule the EA was never taught. The two most frequent: trading through a news window with widened spreads, and a daily loss computed by the firm that the EA's internal limit never accounted for. Both are preventable with a guardrail layer that stops trading before the firm's dashboard would flag it.
Pass the Challenge With an EA That Cannot Breach It
The strategy wins the challenge; the guardrail layer survives it. Send us the rules of the firm you are targeting — we will build the EA around them.