Risk rules — the safety layer that protects your EA from itself
Every EA needs a risk layer that operates independently of its trading logic. Not because the strategy is bad, but because the best strategies can fail in unexpected conditions — and when they do, you need a system that stops the bleeding before the account is damaged beyond recovery. This lesson builds that system.
Ultima revisione:
The 90-second version
Your EA's trading logic tells it when to trade. Your risk layer tells it when to stop. Both are required. Only one gets configured before deployment. Make sure it's the right one.
- Most EA account blowups happen not because the strategy was wrong — but because there was no circuit breaker when it started failing
- A daily loss limit of 3–5% stops a bad day from becoming a bad month
- A drawdown cutoff at 10–15% of account equity means you always have capital left to recover or reassess
- Position size caps prevent a single oversized trade from doing damage a week of wins can't undo
- News filters and magic number isolation are the difference between a professional risk setup and a naive one
MyForexFunds had over 135,000 funded traders, many of them running EAs without consistent risk controls — a fragility that became visible only when the firm collapsed.
La CFTC e il regolatore dell'Ontario hanno congelato gli asset di MyForexFunds nell'agosto 2023, accusando frode. Oltre 135,000 trader finanziati hanno perso immediatamente l'accesso ai loro conti. Il caso resta l'esempio più chiaro del rischio di controparte EA di terze parti + prop firm.
FonteRisk Rules Builder
Toggle each rule on to see how it contributes to your EA's risk protection score. Aim for green before going live.
Unprotected — live deployment not recommended
How EA risk rules actually work
Why risk rules exist — the architecture of controlled failure
Every electrical grid has fuses. A fuse is not an admission that the grid is poorly designed — it is a recognition that unexpected conditions exist, and that when they arrive, you want the damage contained to the smallest possible component. A blown fuse protects the circuit. A tripped breaker protects the building. A halt in trading protects the account.
EA risk rules are the fuses in your trading system. Your strategy logic — the signal layer, the filter layer, the execution layer — can be excellent. It can be backtested, walk-forward tested, run on demo for months. And it can still lose unexpectedly when a regime change arrives that wasn't in the historical data. That is not a failure of the backtest; it is the normal reality of trading a system in a non-stationary market.
Risk rules operate independently of the strategy. They do not know whether a trade is likely to profit. They only know: how much has been lost today? How far has equity fallen from its peak? How large is the current open position relative to the account? When the answers exceed the limits you set in advance, trading stops — cleanly, automatically, without emotion.
The critical insight is that risk rules must be configured before live deployment, not after. The temptation is to launch first and add guardrails after you see what happens. This is exactly backwards. The time you most need the guardrails is the first live week, when the EA encounters real fills, real spreads, and real market conditions for the first time. Configure the rules on demo. Verify they fire correctly. Then go live.
The 5 essential risk rules every EA needs
Rule 1: Daily loss limit. Define the maximum percentage of account equity the EA is allowed to lose in a single calendar day. When this threshold is crossed, the EA closes all open positions and suspends trading until the next trading day. Typical range: 2–5% of account equity. In MT5 EA inputs, this is usually expressed as a parameter named DailyLossLimitPercent or MaxDailyLoss.
Rule 2: Maximum drawdown cutoff. This is a cumulative equity floor — the deepest decline from peak equity that the EA is permitted before all trading halts indefinitely (requiring manual intervention to restart). Where the daily limit is a per-day circuit breaker, the drawdown cutoff is a total-campaign limit. Typical range: 8–15% of starting equity for funded accounts; 15–25% for personal accounts. In MT5 inputs: MaxDrawdownPercent.
Rule 3: Position size cap relative to equity. Lot size must be calculated as a percentage of current account equity, not as a fixed number. A fixed 0.10 lot on a $10,000 account is 1% risk per pip move — but if the account grows to $20,000, that same lot is 0.5%. If it shrinks to $5,000, it is 2%. Capping lot size as a function of equity ensures the EA's risk footprint scales correctly in both directions. Typical range: 0.5–2% of equity per trade, depending on stop-loss distance. In MT5 inputs: RiskPercent or MaxLotPercentEquity.
Rule 4: High-impact news filter. Many EA strategies produce false signals during high-impact news releases — not because the strategy is wrong, but because price behaviour during a 30-minute NFP window is fundamentally different from price behaviour in normal market conditions. A news filter pauses trading for a defined window before and after scheduled high-impact events. Practical implementation: use a freely available economic calendar API or the built-in MT5 calendar to block entries during Tier-1 events (NFP, CPI, FOMC, ECB). In MT5 inputs: NewsFilterEnabled, NewsMinutesBefore, NewsMinutesAfter.
Rule 5: Magic number isolation. If you run more than one EA on the same account, each EA must use a unique magic number — an identifier attached to every order it opens. Without magic numbers, EA-A may attempt to close EA-B's positions, or the drawdown calculation may count positions from both EAs against EA-A's limit. Magic numbers are set as a constant in the EA input panel (typically named MagicNumber or EAMagicNumber). They cost nothing to implement and prevent a category of bugs that is otherwise nearly impossible to debug in a live multi-EA environment.
Risk rules in MT5 Inputs — configuration and testing
In MetaTrader 5, EA parameters are set in the Inputs tab of the EA properties panel (right-click the EA name in the Navigator panel → Attach to chart → Inputs tab). Every risk rule described above should map to a named input that can be adjusted without modifying the EA's code. If an EA's inputs panel has no risk parameters — no daily loss limit, no drawdown threshold, no risk percentage — that is a significant red flag.
To verify that a risk rule works before going live, you need to trigger it deliberately on demo. For the daily loss limit: open the EA on a demo account and set the limit to 0.5%. Then manually open a position in the wrong direction and let it run. Observe whether the EA closes the position and suspends trading when the 0.5% threshold is reached. Check the Expert Journal (MT5 bottom panel → Experts tab) for a message confirming the rule fired. If there is no message, the rule is not firing — investigate before going live.
For the drawdown cutoff: set it low (1%) and trigger it the same way. For position size cap: verify that as you change the RiskPercent input, the calculated lot size displayed in the order preview changes proportionally. For the news filter: check that the EA's trade log shows 'News filter active — skipping entry' around major calendar events. For magic numbers: open two EA instances on the same account with different magic numbers and verify that each EA only acknowledges its own positions.
The Expert Journal is your primary verification tool. A risk-rule implementation that doesn't log when it fires gives you no visibility into whether the protection is active. Professional EAs always log risk events. If yours doesn't, add logging or ask the EA developer to add it before deployment.
Key terms
A cautionary story from 2023
In August 2023, the CFTC and the Ontario Securities Commission acted against MyForexFunds, freezing assets and shutting down a firm that had grown to over 135,000 funded traders — many of them running EAs.
La CFTC e il regolatore dell'Ontario hanno congelato gli asset di MyForexFunds nell'agosto 2023, accusando frode. Oltre 135,000 trader finanziati hanno perso immediatamente l'accesso ai loro conti. Il caso resta l'esempio più chiaro del rischio di controparte EA di terze parti + prop firm.
The MyForexFunds case revealed a structural fragility that extends beyond the specific legal allegations: a large-scale prop-firm operation built on a foundation of EA traders, most of whom had never configured consistent risk rules on their funded accounts. When access was suspended overnight, traders had no visibility into their open positions, no ability to set emergency stops, and no documentation of which EA was running what on which account. The regulatory response exposed what uncontrolled EA risk behaviour looks like at scale — not a single blow-up, but a systemic absence of risk architecture across tens of thousands of accounts. The lesson is not about the legality of the firm. It is about the EA traders: every one of them would have been better protected by a properly configured drawdown cutoff, a daily loss limit, and documented magic numbers. Risk rules are not just about protecting capital in the market — they are about maintaining control of your own system when external events force a sudden halt.
FontePractice
Configure all 5 essential risk rules in the MACD Sample EA
MT5 ships with a MACD Sample EA that includes basic risk parameters. Use it on a demo account to practice configuring and verifying each of the five risk rules — without touching any of your real setups.
- 1
Open MT5 on a demo account. In the Navigator panel, expand Expert Advisors → MACD Sample. Double-click to attach it to a EURUSD H1 chart. In the Inputs tab, locate TakeProfit, TrailingStop, Lots, MaximumRisk, and DecreaseFactor. These are the EA's built-in parameters — you'll add your own risk rules on top.
- 2
Configure the daily loss limit: set MaximumRisk to 0.5% (the MACD Sample uses this for position sizing; treat it as your risk-per-trade proxy). Then create a second demo account, set the initial balance, and calculate what 3% of that balance looks like in dollar terms. Open a counter-trend position manually until that threshold is reached. Observe whether the EA's behavior changes — if it doesn't stop, you have identified a missing risk layer in this particular EA.
- 3
Verify position sizing: change MaximumRisk from 0.01 to 0.02 (1% to 2% risk per trade). Check the Expert Journal to see if the calculated lot sizes for new entries change proportionally. A correctly implemented position size cap produces lot sizes that scale with the input percentage.
- 4
Test magic number isolation: attach a second EA instance to the same account with a different magic number. Confirm in the Trade tab that positions from each EA are separately tracked. In the Expert Journal, check that each EA only references its own positions by magic number.
- 5
Document what fired and what didn't. The MACD Sample is a teaching tool — it may not have a news filter or a drawdown cutoff built in. Note which of the five rules are missing. This is the real exercise: by the end, you should have a written checklist of which risk rules are present in any EA you evaluate, and which need to be added or confirmed with the EA developer before live deployment.
Mastery check
Four questions. Pass at 75% (3/4). Focus on the purpose and configuration of each risk rule — not on specific numbers.
Mastery check — Lesson 9
Metti alla prova la tua comprensione con 4 domande. Supera con 75/4 risposte corrette.
Reflect
Riflessione
Scrivi le tue risposte sincere — salvate solo su questo dispositivo. Usale la prossima settimana per individuare schemi nel tuo modo di pensare al trading.
Pro deep dive
The five essential rules cover individual-EA risk. Professional trading operations add two more layers: portfolio-level risk across correlated EAs, and dynamic risk scaling as a function of recent performance.
Correlation between simultaneous positions
If you run three EAs that each trade EURUSD, GBPUSD, and AUDUSD simultaneously, you have not diversified your risk — you have concentrated it. During a broad USD rally, all three pairs move in the same direction. Each EA's drawdown calculation treats its position in isolation; no EA knows that two other EAs are also losing. Portfolio-level risk control requires a master account monitor that aggregates all open exposure across all EAs before any new position is opened. The calculation: sum all current open lots across correlated instruments, weight them by their correlation coefficient (available from platforms like MyFXBook correlation matrix), and refuse new entries if the weighted aggregate exposure exceeds the portfolio-level cap. Few retail EAs implement this natively — it typically requires a custom monitoring script or the use of a portfolio manager EA.
Dynamic position sizing vs fixed percentage risk
A fixed 1% risk-per-trade rule works well over long sample sizes. It does not reduce lot size during losing streaks and does not increase it during winning streaks — which is correct from a probability standpoint, but ignores the psychological and capital-management reality that a 10-trade losing streak at 1% risk depletes capital faster than it might appear. Fractional Kelly position sizing adjusts lot size as a function of the EA's recent win rate and average win/loss ratio. When the EA is performing above its long-term expectation, fractional Kelly permits slightly larger sizes; when it is underperforming, it reduces exposure. Practical implementation: calculate the Kelly fraction as (win_rate - (1 - win_rate) / avg_win_loss_ratio) and apply a 25–50% fraction of that value to avoid the volatility of full Kelly. This requires tracking rolling win rate and average trade R, which most EA frameworks do not track natively — it must be added to the risk layer.
Emergency stop procedures for multi-EA portfolios
Professional operations document a kill-switch procedure before going live. The kill switch answers: 'If I need to stop all EAs immediately — due to a platform error, a news event, or unexpected drawdown — what is the exact sequence of steps?' A complete kill-switch procedure includes: (1) the keyboard shortcut or script that closes all pending orders; (2) the sequence for closing all market positions (largest first to reduce exposure fastest); (3) the VPS login credentials stored somewhere other than the VPS itself; (4) the broker emergency phone number for situations where MT5 is unreachable. The procedure should be written down and tested on demo quarterly. The goal is that during a high-stress market event, you are executing a memorised procedure, not improvising.
Regulatory perspective on EA risk controls
The MyForexFunds case and parallel regulatory actions in Europe have increased regulator focus on whether retail traders running EAs understand what they are running and what controls are in place. ESMA's 2024 guidelines on algorithmic trading in retail contexts explicitly reference the need for 'pre-defined kill switches' and 'maximum position size controls' — language borrowed directly from institutional algorithmic trading regulation. While these guidelines apply primarily to licensed entities, they signal a direction of travel: regulators increasingly expect EA traders to be able to demonstrate that their systems have defined risk limits, have been tested, and have documented emergency procedures. The practical implication for individual traders: your risk rules documentation is your defence if a broker disputes a trade or an account breach. Keep records of your configured parameters and the date they were set.
Sources
Mostra risposta
Daily loss limit (per-day circuit breaker), maximum drawdown cutoff (cumulative equity floor), position size cap relative to equity (dynamic lot sizing), high-impact news filter (entry suspension during scheduled events), and magic number isolation (unique identifier for each EA's positions).
Solo materiale didattico — non è consulenza sugli investimenti. Il trading comporta il rischio di perdita del capitale. Esercitati sempre su demo e usa uno stop-loss. ← Torna a Automated Trading