Skip to content
TradingTune
Metrics, Risk, and Execution

How do you calculate risk of ruin for a trading strategy?

Estimate risk of ruin by defining a loss threshold, modeling possible account paths and counting threshold crossings.

On this page

Key takeaways

  • Risk of ruin depends on the chosen threshold, time horizon and model assumptions.
  • A path counts as ruined when it touches the threshold, even if it later recovers.
  • Resampling historical trades cannot reveal losses absent from the input data.
  • Compare estimates only when sizing, costs, the horizon and the ruin definition are consistent.

How do you calculate the risk of ruin?

Risk of ruin is the chance that a trading account reaches a defined loss threshold within a specified period or sequence of trades, as estimated under the assumptions used to describe how the account changes during that period or sequence. To estimate it, set the threshold, model possible account paths and count the paths that touch it.

For a finite simulation, use estimated risk of ruin = paths that reach ruin / all simulated paths. A path is the sequence of account values produced by a simulated series of trades, starting from the capital specified for the calculation and ending when the chosen horizon is reached or at an earlier stopping point specified in the model.

Count a path as ruined if it touches the threshold at any point during the simulated sequence, even if the account balance later rises above that level and remains there for the rest of the path. The resulting fraction is an estimate under the model and its stated assumptions, rather than a known chance that describes what will happen to an actual account over the same sequence of trades.

The starting capital, trade outcomes, sizing rules, costs and horizon all affect the answer. Change any of those inputs and the calculation answers a different question, even if the other inputs stay the same, so keep each choice visible whenever you compare estimates or explain a result to another reader who needs to understand what was counted.

A formula can also answer a narrower question when gains, losses and their probabilities follow simple rules. The gambler’s ruin model describes a game with fixed initial stakes and a constant chance of winning. Trading outcomes may not follow those rules about stakes and winning chances, so the formula for the game is not automatically a formula for a trading strategy with outcomes that may follow a different pattern.

What account level counts as ruin?

Ruin needs an explicit boundary before you can count it, and that boundary should be stated before the simulated paths are generated, so the same event is identified consistently throughout the calculation. Complete loss of capital is one possible boundary, but a study can instead use an account level below which the strategy cannot continue under its stated rules, making the event being counted a breach of that operating level rather than the loss of all capital.

The distinction matters because capital can remain above zero while falling below an operating constraint, such as the funds needed to support the next position, so a calculation that counts only complete loss may answer a different question from one that counts a breach of that constraint. Margin is money required to support a position, and a model that includes it needs to state how the requirement affects the account and what happens when the account cannot meet it.

A fixed threshold asks whether the account falls to a stated floor, regardless of any earlier high. A peak-based threshold asks whether the account falls far enough from a previous high, which requires the model to track that high throughout each path and compare subsequent account values with it whenever the boundary is checked during the simulation.

Also specify when the boundary is checked, since a test that uses only closed-trade balances can miss a breach while a position is still open, leaving the estimate limited to the account values observed at the stated checking points rather than every value during the trade. If only closed trades are available, label the estimate as a closed-trade calculation and make clear that the boundary is checked against those available values, rather than presenting the result as a test of every account value while positions are open as well as after they are closed.

The boundary is part of the question, not a universal definition of failure. A reader comparing studies needs to see whether each uses the same floor, the same checking points and the same treatment of a breach before interpreting any difference in the estimates, since each of those choices affects the event being counted.

Which historical data goes into the estimate?

Begin with a trade record for the strategy being studied, including the sequence of gains and losses, the test period and enough information to describe the position sizes used, so the later calculation can be tied back to the strategy and its recorded outcomes. Keep the strategy version and its input settings with that record so the calculation can be repeated later.

A fixed cash result cannot always be reused unchanged when the modeled position size changes with account value. In that situation, a result expressed relative to position size may be useful, provided the record also contains the information needed to apply the chosen sizing rule to each simulated trade as the account value changes along the path.

Check whether costs are already included in the record before adding them to the calculation. Otherwise, the model may count the same expense twice and describe a different set of trade outcomes from the one intended, making the account paths reflect a cost treatment that was not part of the stated calculation.

The record should match the strategy version being examined, rather than combining trades from different rules without explanation. A change to an entry rule, exit rule or sizing rule can make an older trade record a poor description of the current model, even when both tests use the same market data and the records appear similar at a glance.

Historical trades are observations, not a complete list of future possibilities. A sample may contain no severe gap, meaning a price move between available trading points, even though such a move could matter to the modeled position, so an estimate based on the sample alone may leave out an outcome relevant to the question being studied. The guide to common backtesting mistakes covers checks for the data and assumptions behind a backtest.

How do you turn trades into possible account paths?

A practical approach is to draw outcomes from the historical record with replacement, meaning that an outcome remains available for later draws after it has been selected, rather than being removed from the set of outcomes that can be used to build the path. The same recorded trade can therefore appear repeatedly in a path, while another recorded trade may not appear in that path at all, because each draw is made from the available record rather than from only the trades that have not yet been selected for the path.

Apply each draw to the simulated account under the stated sizing and cost rules, and check the ruin boundary at the points your data allows, so that each recorded breach reflects both the available account values and the rules chosen for this particular calculation. Repeat the process for many paths using the same starting account, boundary and horizon, so each path answers the same question and the resulting count can be interpreted against that shared set of conditions.

Stop a path at the boundary or continue recording it while marking the breach as final for the count. Either approach must count the path as ruined even if a later modeled gain would put the balance back above the threshold, because the event being counted is the boundary being touched during the path.

The Monte Carlo method describes a broad class of calculations based on repeated random sampling. The site’s Monte Carlo robustness guide covers the wider use of resampling to examine a strategy’s historical trade record.

Drawing individual trades allows any selected outcome to follow another under the model, which can remove patterns present in the original sequence and make the simulated ordering different from the ordering in the historical record. Drawing blocks of consecutive trades instead preserves order within each selected block, although it still rearranges the blocks and cannot establish that future sequences will behave the same way as the historical sequences used to construct the blocks in the model.

How do sizing and costs change the calculation?

Position sizing is the rule that determines how large a position is relative to available capital or another stated amount, and the rule needs to be described when calculating how each trade changes a modeled account. It belongs inside the path calculation because the same trade outcome can change the account by a different amount when the position size changes.

With fixed cash sizing, the model applies outcomes in fixed monetary units until a rule or constraint changes the position, so the calculation needs to state both the fixed basis and any condition that changes it. With proportional sizing, the modeled amount changes with account value, so the calculation must update the position size before applying each new outcome, using the account value and the stated sizing rule for that point in the path rather than assuming that the starting position size remains unchanged.

State what happens if the account cannot support the next position, because that condition may itself be the chosen ruin event or may require another explicitly stated treatment within the model before the path continues. If it is not the ruin boundary, the model still needs a clear rule for whether trading stops, the position changes or the path continues in another stated way, so that the calculation does not leave the next step undefined.

A stop is an instruction intended to limit a loss, but the modeled fill can differ from the stop level, so the intended limit and the amount applied to the account need not be the same. A calculation that caps every loss at the planned amount may therefore omit a loss that exceeds the intended limit, unless the model explicitly allows for it when generating outcomes and applying them to the account under the stated sizing rules.

Commission is a trading fee, while slippage is the difference between an expected price and a modeled or actual fill price, so each describes a different part of the cost treatment used in a calculation. Include assumed costs either in the recorded outcomes or in the path calculation, without counting them twice; the cost modeling guide explains the related backtest assumptions.

How can you check the inputs by hand?

A manual check starts with a list of parameter combinations and a note of the strategy version, data period and sizing rules used for each test, giving the reader a record of the inputs and conditions behind the trade records being compared. A parameter is an input that changes how the strategy operates, such as a lookback length or an exit condition, and its chosen value is part of the description of the combination being tested.

Run the backtest for each combination and keep its trade record separate, along with the settings needed to identify how that record was produced, so that the outcomes used in the later calculation can be matched to the particular inputs and test conditions that produced them. Apply the same ruin boundary, horizon, cost treatment and path method to each record before comparing the resulting estimates.

Without that shared setup, a difference may come from the calculation rather than the strategy inputs. For example, a changed boundary can alter which paths count as ruined even if the underlying trade records are unchanged and the same records are used to generate the paths.

Inspect the records for missing trades, position-size changes, costs counted twice and outcomes expressed on inconsistent bases. Keep a note of every combination tried, including those set aside, so the final comparison shows the scope of the search rather than presenting a selected record without the context of the other combinations considered during the manual check.

The ruin calculation is separate from the backtest used to collect its inputs, and a ranked backtest result is not by itself an estimate of crossing the chosen boundary under the account model and horizon specified for the ruin calculation. The manual parameter sweep article describes the related work of testing input combinations.

TradingTune for Chrome

Stop tuning your strategy's inputs by hand.

Add to Chrome, it's free

Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.

What does the time horizon change?

The horizon sets how long each simulated path has to reach the boundary, and it must be specified before the paths are counted. It can be expressed as market time or as a sequence of trades, but those choices ask different questions when trading activity varies over time.

A model based on a fixed trade sequence needs an extra assumption about when trades occur if the question concerns a calendar period, because the sequence alone does not specify how those trades are distributed through the period being examined in the calculation. Conversely, an estimate for a stated sequence of trades should not be presented as a calendar-period probability without a model that connects the trades to time and makes clear how the specified sequence relates to the calendar period being described to the reader.

A longer horizon gives a path more opportunities to touch a fixed boundary, provided the same modeled rules continue to apply and the longer path is evaluated under the same boundary definition as the shorter one. Comparisons across different horizons can therefore be misleading, even if the starting capital, outcome data and boundary are otherwise identical, because the paths have different lengths in which to reach that boundary.

State what the model does if the strategy stops trading before the horizon ends. The result can be hard to interpret if one calculation stops at that point while another assumes that outcomes continue to be drawn from the historical record, since the paths are then governed by different assumptions about what happens after trading stops.

An eventual ruin question, with no fixed end, is different from a finite-horizon simulation. Running long simulated paths does not by itself establish the eventual probability, and an analytical answer for an unlimited horizon depends on its own assumptions about outcomes and how they repeat, which need to be stated alongside that answer.

How reliable is the estimated chance?

The estimate has uncertainty from both the simulated paths and the trade record used to generate them. Sampling uncertainty arises because a finite set of random paths is used, so another run of the same calculation can produce a different fraction even when the inputs are unchanged and the same method is used to generate the paths.

Repeating the calculation can show how much the estimate moves under the same model, but it cannot correct a flaw in the assumptions or add outcomes absent from the source record. Keep that variation separate from uncertainty about whether the historical trades represent future conditions.

The discussion of the Kelly criterion notes that outcome probabilities are rarely fully known in investments, a useful warning for any model that depends on estimated chances. The historical record may not represent the range, frequency or order of future outcomes, and a short record can leave important losses unseen, so the model built from that record may omit outcomes or sequences that matter to the boundary being examined in the calculation.

Compare assumptions without changing the question being asked: for example, draw individual trades in one model and consecutive blocks in another while keeping the boundary and horizon unchanged, so the comparison focuses on the choice of how outcomes are drawn. Examine cost and sizing assumptions separately, and describe the resulting differences rather than selecting an estimate without its context.

A simulation may show no breaches in the paths it generated, but that is not proof that the underlying chance is zero, because the observed count is based on a limited set of modeled paths. Rare outcomes may be missing from the record, and the number of simulated paths is limited; the minimum trade count guide discusses the evidence behind backtest statistics.

How should you report the result?

Put the ruin boundary, starting capital basis, horizon and sizing rule beside the estimate, so a reader can see exactly which event the calculation counted and can understand the conditions under which the paths were generated before interpreting the reported fraction. Identify the trade record, the cost treatment and the method used to generate paths, including whether the boundary was checked only at trade close, so a reader can tell what information was used and what account values were available when breaches were counted.

Describe the estimate as conditional on those choices rather than as a property that remains unchanged across all account models, since a different model or boundary can answer a different question. If paths draw from historical trades, say so, and note that the model cannot generate an unseen loss unless it explicitly allows for one, so the reader can distinguish the outcomes present in the record from those that the model has not included.

When paths use blocks, record how the blocks were selected and how the model handled the end of each block. That detail matters because preserving order within a block does not preserve the entire original sequence, and a different block choice can change the paths being counted even when the same historical trade record is used to form the blocks.

Keep the original trade data and calculation settings with the report, including any alternatives examined for costs, sizing or the boundary, so that a later reader can identify the inputs and choices behind the estimate. This makes a later check possible without confusing a changed strategy or data set with a changed definition of ruin.

The calculation addresses a boundary-crossing question, not whether a strategy should be traded. Its value lies in making the model and its limits visible, so another reader can inspect the assumptions behind the estimated chance.

Sources

TradingTune for Chrome

Stop tuning your strategy's inputs by hand.

TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.

Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.

Share this post