Per-EA Risk Envelopes: Giving Every Expert Advisor Its Own Budget on a Shared Account

25 October 2026, 12:14
Michael Thomas Harty
0
27

Running several EAs on one account is efficient, and it hides a problem: the account has one equity curve, but each EA has its own behaviour. When the account is down 9%, which EA did it? Is that within what each one normally does, or has one of them broken? Without a per-EA budget, the only stop you have is the account-level one, which arrives late and takes everything down with it.

A risk envelope is a small set of limits that belongs to one EA. It answers one question in advance: "At what point does this EA stop being trusted to keep trading on its own?"

What goes in an envelope

Limit What it caps Example (illustrative)
Allocation Share of account equity the EA is sized on 25% of equity
Risk per trade Loss at stop as % of allocation 0.5%
Max open risk Sum of risk on all its open positions 1.5% of allocation
Daily loss Realised + floating loss today 2% of allocation
Envelope drawdown Peak-to-trough on the EA's own P/L 12% of allocation
Max positions / lots Hard count and size caps 3 positions, 0.30 lots
Behaviour Trades per week, longest hold 2–12 trades, < 5 days

Every number is set from the EA's own history, with headroom, not from hope.

Setting the drawdown limit from evidence

A common approach (illustrative numbers throughout):

  1. Take the EA's maximum drawdown from a long, realistic backtest including costs: say 6% of allocation.
  2. Check forward/demo results for the same period length. Live drawdowns are usually deeper than backtests; suppose the demo reached 7.5%.
  3. Apply a multiplier for "worse than seen so far": 1.5× the larger figure gives roughly 11%.
  4. Round to a limit you can explain: 12%.

If live drawdown passes 12%, the EA is outside anything its history justified. That does not prove it is broken, but it ends automatic trust.

Losing streaks deserve the same treatment. With a 45% win rate (illustrative) the chance of a given trade starting a run of 8 losses is 0.55⁸ ≈ 0.8%; over a few hundred trades, at least one such run becomes likely. Size risk-per-trade so that a streak like that stays well inside the envelope.

Attributing P/L to each EA

The envelope only works if you can measure each EA separately. In MT5 that means a unique magic number per EA instance, and filtering everything by it.

// Illustrative: realised P/L for one magic number since a start time double RealisedPL(long magic, datetime from) { double pl = 0.0; if(!HistorySelect(from, TimeCurrent())) return 0.0; int n = HistoryDealsTotal(); for(int i = 0; i < n; i++) { ulong t = HistoryDealGetTicket(i); if(HistoryDealGetInteger(t, DEAL_MAGIC) != magic) continue; long entry = HistoryDealGetInteger(t, DEAL_ENTRY); if(entry != DEAL_ENTRY_OUT && entry != DEAL_ENTRY_INOUT && entry != DEAL_ENTRY_OUT_BY) continue; pl += HistoryDealGetDouble(t, DEAL_PROFIT) + HistoryDealGetDouble(t, DEAL_SWAP) + HistoryDealGetDouble(t, DEAL_COMMISSION); } return pl; } // Floating P/L for one magic number double FloatingPL(long magic) { double pl = 0.0; for(int i = PositionsTotal() - 1; i >= 0; i--) { if(PositionGetTicket(i) == 0) continue; if(PositionGetInteger(POSITION_MAGIC) != magic) continue; pl += PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP); } return pl; }

Track the EA's own equity line as allocation + cumulative realised + floating, keep its running peak, and the envelope drawdown is simply (peak - current) / allocation . Include commission and swap; leaving them out flatters every EA a little and some EAs a lot.

Two practical notes:

  • Manual trades and other tools must use their own magic numbers (or 0) so they never pollute an EA's figures.
  • Re-attaching an EA with a new magic number silently resets its history. Record magic numbers in a register and change them only deliberately.

What happens at each limit

Decide the response before it is needed, and make it proportionate:

Level Trigger (illustrative) Response
Watch 50% of daily loss or envelope DD used Note it; check behaviour matches profile
Warn 75% used, or behaviour outside profile Human review today; no new allocation
Stop new entries 100% of daily loss EA stops opening trades until next day
Suspend 100% of envelope DD, or position/lot cap breached EA disabled; open positions handled by a written rule; review before restart

Write down how open positions are handled at "Suspend" (close, leave to their stops, or reduce), because deciding under pressure is how small problems become large ones.

The account still needs its own limit

Envelopes do not replace an account-level cap; they sit underneath it. If five EAs each have a 2% daily limit, the account can still lose 10% in a day when they all hit at once, which is exactly what happens on correlated news. Set an account daily limit below the sum of the envelopes, and check how correlated your EAs actually are (same symbols, same session, same signal type).

The monthly envelope review

Once a month, for each EA:

  • Envelope usage: peak drawdown versus the limit, days the daily limit was touched.
  • Behaviour: trades and holding times versus the profile.
  • Backtest-versus-live drift: is live performance per trade drifting below the backtest by more than costs explain?
  • Decision: keep, reduce allocation, or retire. Changes to allocation are made here, not mid-month after a good or bad week.

Summary

  • Give every EA its own allocation, loss limits and behaviour profile.
  • Set limits from evidence plus headroom, and include all costs.
  • Attribute everything by magic number and keep a register.
  • Pre-agree the response at each level, and keep an account cap below the sum of envelopes.
  • Review monthly and change allocations only at the review.

An envelope does not make an EA better. It makes it clear, early and without argument, when an EA is no longer behaving like the one you tested.

Virtual Risk Desk

All figures, limits and code are illustrative and untested for any specific account. This is educational content about risk process, not trading or investment advice. Past or backtest performance does not indicate future results.