Monte Carlo
How solid is a result? Monte Carlo replays a backtest's trades or a portfolio's days in thousands of other orders to show the range it could land in.
What it tells you
A backtest is one history: one order of wins and losses, one path through the market. Had the same trades come in another order, the deepest drawdown or the worst year could have been very different. Monte Carlo draws thousands of alternative paths from the same results and shows where the real one sits among them.
It works on what was already recorded: it never runs the strategy again, and it cannot invent a market the backtest did not see. A result whose paths all look alike is sturdier than one that only the real order made look good.
You find it in three places:
- on a backtest's report, from its trades;
- on a portfolio, from its combined days;
- inside the prop simulator, on the days it replays through a firm's rules.
On a backtest
Open a finished backtest and pick the Monte Carlo tab. It is computed when you open it, in a moment. Two settings change it, then Run: the number of paths, and the seed (the same seed gives the same numbers on every visit).
Two ways to draw the paths:
- Reorder trades: the run's own trades in random orders. Every path ends at the same balance; only the way there changes, so the drawdowns and the losing streaks are what move.
- Resample trades: trades drawn at random with replacement: some repeat, some drop out, so the final balance varies too.
Position sizing says how the strategy sizes its trades. Fixed size: each trade's money is replayed as it is, from the deposit. Grows with the account: a strategy that works out its volume from the balance makes bigger trades as it grows, so each trade is replayed as a return on the balance it was sized on (the backtest records that balance with every trade), and on each path it is that path's balance that sizes it. A late trade, made when the account had grown, is not dropped at full size onto a fresh deposit. The page picks it for you from the strategy's volume (or assumes fixed when it recognises no balance-based volume) and says which; change it if it is wrong.
A backtest run before each trade recorded that balance cannot be replayed as growing: picked by you, the page says so and asks you to re-run the backtest; picked for you, the trades are replayed as fixed and a note says why. When positions overlapped, a growing replay in the trades' own order may not end exactly where the backtest did (a trade's return is on the balance it was sized on, and other positions closed in between); a note says so, and the paths are built the same way, so they still compare with each other.
The paths are drawn as a fan, trade by trade from the deposit (the dashed line): a light band from the 5th to the 95th percentile, a darker one from the 25th to the 75th, the median, a few paths drawn whole, and this run's own balance through them. Under it: the drawdown the worst 5% of the paths reached or exceeded, this run's own, and where the paths end.
Then each figure is ranked against the paths: Max drawdown, Max drawdown %, Longest losing streak and, with Resample trades, Final return %. Each row gives this run's percentile among the paths (a drawdown at the 62nd percentile is deeper than 62% of them) and its range: a pill from the 25th to the 75th percentile, a tick at the median and a dot at this run. Three shares follow: Deeper drawdown, Ended below deposit, Lost the deposit.
Read it with two limits in mind:
- Closed trades only. The drawdowns are of the closed balance, trade by trade: what a trade lost while still open is not in them, so they can read shallower than the report's equity drawdown.
- Each trade stands alone. Shuffling trades assumes their order does not matter. For a strategy whose trades depend on each other (a grid, a martingale, positions that overlap), the shuffle breaks that link: read its paths with care.
A run needs at least 20 closed trades. Money booked outside any trade, such as swap charged to the balance, is not resampled.
On a portfolio
Open a portfolio and pick the Monte Carlo tab, then Run Monte Carlo.
Here the unit is a day, not a trade. The portfolio's reference backtests are added up into one account, day by day (UTC days; a day with no record in any backtest, such as a weekend, is skipped). Monte Carlo cuts those days into short blocks of consecutive days, so a bad week stays a bad week, and strings blocks together at random. Four options sit beside Run Monte Carlo:
- Paths: how many alternative histories to draw.
- Average block: how many consecutive days are kept together, on average. Longer blocks keep longer streaks.
- Path length: each path's length; empty is as long as the history.
- Seed: the same seed gives the same numbers.
The result reads as on a backtest, in percent and over days: the fan of the paths' return from the start, with the history's own curve through it; the fall the worst 5% of the paths reached, the history's own and the median return; then CAGR, Max drawdown %, Worst year and Final return % ranked against the paths, the history as the dot, and the share of paths that end in a loss or lose everything. A run made before the fan existed shows the figures without it. Under a year of days there is no CAGR or worst year. Backtests in different account currencies are combined as percentages, and backtests on different deposits are scaled to one account, as on the dashboard.
Each path replays its days the way each strategy sizes (Position sizing on the slot, Portfolios). A Fixed size strategy adds the money it made that day, whatever the account holds by then: it does not trade bigger after a good run or smaller after a bad one. A strategy set to Grows with the account makes the same return on whatever the path's account holds, so its money grows and shrinks with it (the result names those strategies). The history's own curve is replayed the same way, so for fixed-size strategies it is exactly the combined account the dashboard shows.
A run is kept: you can leave the page, and it waits among the past runs. It needs at least 60 days with a record, read from the account record the platform keeps with each backtest. Backtests run before that record existed, and older backtests of a strategy that grows with the account whose record does not hold its starting size, are named, with an offer to re-run them (same revision, same settings); the portfolio then points at the new runs by itself. Each re-run counts toward your plan like any backtest. Monte Carlo runs and prop simulations share a limit of three at a time.
What it does not tell you
- The future. Every path is built from the past. A market unlike anything in the history is in none of them.
- Overfitting. Paths drawn from an overfitted backtest inherit its luck. Monte Carlo shows how fragile a result is to order, not whether its rules were tuned to the data; for that, read overfitting and validation.
- Costs the backtest did not pay. The paths carry each backtest's own spreads, commissions and swaps.
Questions?support@algotradinghub.io