Skip to content

Monte Carlo Simulation

Monte Carlo analysis explores outcomes under a chosen randomization model. In Stratifyre, trade resampling uses completed outcomes from a baseline backtest, while parameter perturbation reruns the strategy with changed inputs. Use the results to investigate losing runs, drawdown exposure, and sensitive parameters before making a risk decision.

The results are conditional on the source trades, execution assumptions, and sampling method. They do not forecast market prices, establish an entry edge, or assign calibrated probabilities to future trading outcomes.

A profitable backtest can still contain a payoff pattern that creates uncomfortable losing runs. Your historical sequence is one observation; resampling explores how its recorded outcomes behave in synthetic sequences.

For example, a synthetic account starts at $10,000 with three +$1,500 outcomes and three −$1,000 outcomes. Alternating wins and losses gives an 8.70% maximum closing drawdown. Placing the losses first gives a 30% drawdown. Both finish at $11,500 because the fixed dollar P&L is unchanged. The example excludes open-position fluctuations, sizing changes, and execution constraints.

The risk question is whether the account path crosses a limit you need to respect. It is not whether historical prices could actually have occurred in that new order. The original chronological backtest remains necessary for understanding signals, fills, and market context.

A zone retest or event-driven entry depends on what was observable at that moment. Resampling treats the completed outcome as an observation; it does not place the historical zone, news release, or fill onto another market date.

Use a consistently defined trading process and retain the original context. Trades around one announcement, overlapping positions, and partial exits can be related observations. A coded approximation of discretionary rules measures that approximation, including any differences in selection or execution.

Stratifyre’s workflow below starts with a saved strategy and baseline backtest. A separate journal worksheet can illustrate the same methodology; this guide does not describe an external trade-journal import feature. For a practical explanation, read Monte Carlo for discretionary zone and event traders.

The engine takes completed outcomes from one baseline backtest, creates new sequences, and reconstructs equity after each sampled outcome. Each path contains the same number of observations as the baseline, but the method determines whether individual observations can repeat.

Method in the formSampling ruleWhat it tests and assumes
StandardDraw individual outcomes with replacementOutcomes can repeat or be omitted, so both order and total P&L can change. Independent sampling discards the original dependence between neighboring observations.
BlockDraw contiguous groups with replacementPreserves order within selected groups; joins between groups change. The native implementation uses non-wrapping blocks and truncates the final sampled block to the path length.
ShufflePermute the source outcomes without replacementEvery outcome occurs once. Fixed additive total P&L stays the same while losing runs and drawdowns can change.

For Block, set Block Size to the number of consecutive observations per group. A size of 1 behaves like Standard sampling. A longer block preserves a longer local pattern, but consecutive trades are not necessarily one session, event, or regime. No block size automatically resolves dependence or changes in market conditions.

“With replacement” means a source outcome remains available after being drawn. It can therefore appear several times in one path. This is the bootstrap mechanism described in SciPy’s documentation. Block algorithms have different boundary conventions; the arch time-series bootstrap documentation distinguishes common variants.

Completed records can be matched segments from partial closures rather than one row per trading idea. Check the observation unit before interpreting sample size, independence, or streaks.

Parameter Perturbation (Sensitivity Analysis)

Section titled “Parameter Perturbation (Sensitivity Analysis)”

This mode varies strategy inputs, such as indicator periods or thresholds, and reruns the historical backtest for each variation. Signals, orders, and completed trades can change, unlike a shuffle of an existing outcome list.

Use it to examine whether a chosen input sits in a stable neighborhood or whether nearby values cause large changes. A sharp change deserves investigation; it does not alone prove overfitting. Compare the rule meaning and resulting trades as well as aggregate metrics.

Randomized parameter search in Walk-Forward Analysis is a separate selection task. Searching for a strong candidate is different from evaluating the sequence risk of a fixed trade list.

  1. Open the Backtest panel for a saved strategy.
  2. Under Monte Carlo, select Enable Monte Carlo, then choose Configure Monte Carlo Parameters.
  3. Set Iterations. For example, start with 1,000 and check whether relevant summaries stabilize across runs. The control accepts up to 10,000; more paths do not add new observed trades.
  4. Under Fuzzing Mode, choose Auto for parameter perturbation or Bootstrap for trade resampling.
  5. For Bootstrap, choose Standard, Block, or Shuffle under Simulation Method. Selecting Block exposes Block Size.
  6. Return to the backtest configuration and click Start. The completed run includes the Monte Carlo results.

Retain the baseline, requested and completed iterations, method, block size where applicable, and seed for reproducible comparisons. Use consistent capital, data windows, and execution assumptions when comparing strategies.

The native bootstrap adds recorded net account P&L to starting equity, one sampled outcome at a time. It retains the baseline’s realized outcome amounts. It does not rerun signals, resize quantities against each synthetic balance, execute margin checks, or reconstruct open-position equity between closures.

Consequently, the sampled closing-equity drawdown can differ from the original backtest’s account drawdown. Costs and accounting should be reconciled in the baseline first; resampling does not repair missing costs or invalid fills. Return-based statistics retain the source position-return percentages, while equity and total P&L use net account amounts, so these are not one uniformly net account-return series.

For a separate sizing worksheet, declare whether inputs are fixed currency P&L, account returns, or R-multiples relative to each trade’s initial risk. Applying a different sizing policy requires recalculating the synthetic outcome amounts under that policy.

If every losing trade loses a fixed fraction f of current equity, k consecutive full-risk losses reduce the balance by 1 − (1 − f)^k, assuming no additional costs or gaps. Ten losses at 1% risk produce a 9.56% decline; at 2%, an 18.29% decline. That percentage is the same whether the isolated streak starts early or after prior profits.

Unconstrained fixed-fraction compounding of the same return basket also preserves final equity under permutation. Capital floors, changing sizing rules, minimum quantities, overlapping exposure, and liquidation constraints require additional modeling; they cannot be inferred from a closed-outcome shuffle.

The chart summarizes sampled equity at each step using percentiles:

  • P5: a lower-tail equity value, with roughly 5% of sampled values at or below it.
  • P25 and P75: the lower and upper quartiles.
  • P50: the median sampled value.
  • P95: an upper-tail equity value, with roughly 95% at or below it.

These bands are conditional summaries, not guaranteed future ranges. Pointwise percentiles can come from different paths at different steps; a band boundary need not be one realizable trading path. Wide bands indicate dispersion under the selected model. Narrow bands do not establish a valid model or a repeatable edge.

Maximum drawdown is each path’s largest percentage decline from a preceding equity peak, including starting equity. The median summarizes the middle sampled drawdown; P95 summarizes the upper tail of drawdown magnitude. Neither is a ceiling on future losses.

Keep this separate from terminal-return percentiles: P5 return and P95 drawdown describe different quantities. If many sampled drawdowns exceed the historical drawdown, investigate sequence sensitivity and whether your risk limits or model assumptions need revision.

This statistic is the fraction of sampled paths whose maximum peak-to-trough drawdown reaches or exceeds the configured threshold (ruinThreshold, default 50%). It is not a bankruptcy or margin-liquidation forecast and is not measured only from starting capital.

For example, a synthetic path rising from $10,000 to $20,000 and falling to $10,000 has a 50% drawdown even though it ends at starting capital. It meets a 50% threshold. Record the selected threshold and path length beside any breach percentage.

Zero observed breaches means none occurred in the completed sampled paths. It does not establish zero risk, account for unseen losses, or justify a universal acceptable breach rate.

Inspect the median and lower tail of terminal equity under the selected method. There is no required distribution shape. In a fixed-P&L shuffle, terminal equity is unchanged across paths, apart from numerical rounding; bootstrap and parameter perturbation can produce different terminal values.

Parameter mode can report which inputs have the strongest association with changing results. Examine the affected trades and parameter ranges before drawing a conclusion. Sensitivity analysis is unavailable for bootstrap because those paths resample existing outcomes instead of varying rule inputs.

Dependence, sample quality, and overfitting

Section titled “Dependence, sample quality, and overfitting”
  • Related outcomes: trades from one event, correlated instruments, and overlapping positions can share exposure. Independent sampling removes those relationships. Compare grouped or chronological analysis where needed; blocks preserve only some local structure.
  • Changing regimes: a sample dominated by one trend or volatility regime may not describe another. Resampling cannot make the source process stable over time.
  • Small samples: a short history can illustrate sensitivity, but additional iterations do not supply unobserved events or new market evidence. Avoid a universal trade-count or iteration-count pass mark.
  • Selection and discretion: keep all qualifying executed outcomes, including losses. Record skipped opportunities separately to examine selection decisions; do not add unexecuted hypothetical P&L to the observed sample. Keep zone definitions and discretionary rules consistent.
  • Overfitting: parameter fragility, sequence exposure, and evidence of an entry edge are different questions. Wide bands, high drawdown, or a favorable median cannot independently diagnose overfitting or validate the rules.

Use chronological out-of-sample testing and forward evaluation alongside Monte Carlo. Record how rules were selected, retain unfavorable results, and investigate changes to assumptions instead of choosing a method solely because it gives a more attractive answer.

Define the decision before running the simulation: which drawdown or exposure would require reducing size, stopping, or collecting more evidence? Choose a method suited to that question, inspect the source outcomes and dependence, and compare the completed results with the stated limit.

If the sampled paths are concerning, test revised sizing or exposure in a new backtest with explicit assumptions. If they are acceptable, retain them as one piece of evidence alongside the original chronological results. For a recorded calculation example, see trade order and drawdown.