Risk of ruin is the probability that a trading account reaches a defined loss boundary under a specified model and time horizon. Ruin can mean zero capital, a fixed capital floor or a drawdown from a running peak. The answer depends on that definition, position sizing and the distribution of trade outcomes. A fixed-stake formula and a fixed-fraction simulation answer different questions; neither produces a universal probability for a real strategy.

This page in the trading metrics library separates the classical gambler's-ruin calculation from the browser simulator below. The simulator estimates the share of modelled paths that breach a peak-based drawdown boundary within a chosen number of trades.
Risk of ruin at a glance
Scroll horizontally to read every column.
| Required definition | Why it changes the answer |
|---|---|
| Ruin boundary | Zero capital, a fixed floor and a trailing drawdown limit are different events. |
| Horizon | Before a target, within a trade count and at any future time are different probability questions. |
| Position sizing | A fixed cash stake removes the same amount on each loss; a fixed fraction changes with equity. |
| Outcome model | Win probability, payoff sizes, costs, dependence and gap losses determine the paths. |
| Calculator on this page | Seeded, finite-horizon simulation of independent fixed-fraction trades and peak-based drawdown. |
What is the simple risk of ruin formula?
The classical equal-payoff model changes capital by one fixed cash unit on every trade: +1 unit with probability p and −1 unit with probability q = 1 − p. Trades are independent and the probabilities do not change. Starting capital is n whole units; ruin occurs at zero.[1]
For 0 < p < 1 and an upper target of B whole units, where 0 < n < B:
Probability of ruin before reaching B = [(q/p)n − (q/p)B] ÷ [1 − (q/p)B], when p ≠ q
Probability of ruin before reaching B = 1 − n/B, when p = q = 0.5
Karl Sigman's lecture notes derive these results for the gambler's-ruin boundary problem.[1] The formulas assume no cash flows, no variable stakes, no costs beyond the stated outcomes and no jump that skips a boundary. A fixed capital floor above zero can be handled by measuring n and B above that floor, if the unit-step assumptions still hold.
With no upper target and an unlimited number of trades, the same fixed-stake model gives:
Probability of ever reaching zero = (q/p)n if p > q; otherwise 1
The closed forms apply to fixed cash stakes and equal payoffs. Substituting account equity divided by a percentage stake does not turn them into fixed-fraction formulas.
A fixed-stake calculation with round numbers
Illustrative assumptions, not a recommendation or strategy results. Start with 500 USD, use a 100 USD stake and stop at either zero or 1,000 USD. Each independent outcome is +100 or −100 USD, with p = 0.60 and q = 0.40. Then n = 5, B = 10 and q/p = 2/3.
- Ruin before the target: [(2/3)5 − (2/3)10] ÷ [1 − (2/3)10] = 32/275 ≈ 11.64%.
- Ruin at any future time, with no target: (2/3)5 = 32/243 ≈ 13.17%.
- Same cash boundaries, 50 USD stake: n = 10 and B = 20. Keeping the same hypothetical probabilities gives 1,024/60,073 ≈ 1.70% before the target.
The stake change alters the boundary-crossing probability substantially without changing the assumed win probability. Actual trading may not preserve payoff sizes, costs and execution conditions when the stake changes. The numbers demonstrate model sensitivity, not an acceptable risk level.
How does fixed-fraction sizing change the problem?
Let f be the fraction of current equity lost on a full losing trade, and b the win amount per unit lost. In the simplified two-outcome model, with 0 < f < 1 and b > 0:
After a win: equity × (1 + f × b). After a loss: equity × (1 − f).
Even with equal payoffs, b = 1, the cash step now changes with equity. After k consecutive losses, equity is starting equity × (1 − f)k. Starting at a peak, the drawdown is 1 − (1 − f)k.
Illustrative, not suggested fractions: five full losses at f = 0.02 produce about 9.61% drawdown. The same five losses at f = 0.05 produce about 22.62%. The position sizing method changes the loss path even when the sequence of wins and losses stays identical.
Under this ideal arithmetic, a positive account never reaches exactly zero in a finite number of losses when every loss costs less than all current equity. That does not establish practical survival. A nonzero capital floor, drawdown limit, minimum tradable size or a loss larger than assumed can end the process sooner.
The horizon matters particularly for a trailing drawdown boundary. With independent trades and a nonzero loss probability, an unlimited sequence eventually contains a losing run long enough to cross any specified drawdown level below 100%. A finite-horizon probability and an “ever” probability therefore need separate labels.

Worked example: the risk of ruin calculator
Illustrative simulation inputs, not measured strategy results or recommended settings. The widget starts each run at normalised equity of 1 and uses the following assumptions:
| Input | Illustrative value |
|---|---|
| Independent win probability | 40% on each simulated trade. |
| Payoff | Each winner +2R; each loser −1R. |
| Loss fraction | 1% of current equity on each losing trade. |
| Ruin definition | At least 20% drawdown from the running peak. |
| Trade horizon | 200 trades in each run. |
| Number of runs | 2,000. |
A win multiplies equity by 1.02 and a loss by 0.99. Model expectancy is (0.40 × 2) − (0.60 × 1) = +0.20R. With the widget's input-derived seed, 137 of 2,000 runs hit the boundary: 6.85%. Median maximum drawdown across all runs is about 11.9%.
Illustrative simulation
Risk of ruin simulator
Win: equity x (1 + r x payoff). Loss: equity x (1 - r).
r is the risk per trade as a share of current equity, so position size compounds. Each trade wins with probability W, independently of the others. A run counts as ruined when its peak-to-trough drawdown reaches the ruin level. Wins are payoff R and losses are 1R after costs; these sizes and probabilities stay fixed. The Monte Carlo runs are seeded from the inputs, so identical inputs give identical results.
Worked example with the default inputs.
- Runs that hit the ruin level
- 6.85%
- Ruined runs
- 137 of 2,000
- Median max drawdown
- 11.9%
- Expectancy per trade (R)
- 0.20
Seed 4F9C90AB, derived from the inputs.
The result measures drawdown over the entered number of trades, not the probability of losing the entire account or a broker stop-out. Zero ruined runs means none in this finite sample. The model leaves out serial dependence, gaps and changing payoffs.
Illustrative calculator. Not a recommendation.
The example was independently recomputed from the widget's algorithm in Python. It is a model output, not an estimate from observed customer trading. Its positive expectancy coexists with a nonzero chance of breaching the specified drawdown level.
What exactly does the browser simulator measure?
- Compounding: each outcome uses the current equity, not the initial account value.
- Independent binary outcomes: every win pays exactly bR and every loss costs exactly 1R. The entered payoff is treated as a fixed outcome, not a distribution of winner sizes.
- Peak-based boundary: a run counts if drawdown reaches the selected level at any point, even if equity later recovers.
- Finite horizon: the percentage refers to the selected number of trades. There is no upper capital target and no estimate of survival forever.
- Full simulated paths: the calculation continues after a breach. The median maximum drawdown uses the entire horizon across all runs.
- Repeatability: the seed is derived from all six inputs, so identical inputs give identical results in this widget. Changing inputs, including the run count, changes the seed.
The calculation runs in the browser. Repeatability makes an example reproducible; it does not remove uncertainty in the input estimates or make the binary model accurate. A displayed zero means no simulated runs crossed the boundary in that sample, not that crossing is impossible.
Why do real strategies need richer simulation?
A single win probability and average payoff ratio discard variation within the wins and losses. They also omit dependence between trades, overlapping positions, changing costs and losses beyond the initial stop. Those details can determine whether an account breaches a boundary.
A Monte Carlo trading simulation can model a distribution of results and explicit account rules. Resampling individual historical trades still assumes that their ordering is exchangeable. Keeping blocks together can represent some observed clustering, but it does not create evidence of losses missing from history.
Define the boundary first, then test which assumptions change the answer: payoff tails, clustered losses, sizing rules and execution costs. More runs reduce simulation noise under a model. They do not correct a model built on the wrong loss process.
What changes when TradingView alerts become MT5 orders?
The path is idea → measurable rule → TradingView alert → MT5 order. TradingView's strategy report describes trades produced by its broker emulator, which simulates fills from chart data.[2] A ruin model built from those trades inherits their cost, fill and sizing assumptions.
PineConnector's syntax reference distinguishes a cash loss budget from a percentage of balance or equity. Loss-based sizing requires an explicit stop, and actual losses can differ because of costs, fills, gaps and broker limits.[3] A strategy-only stop does not establish that an equivalent stop exists at the broker.
Keep the condition becoming true, the alert triggering, webhook delivery, PineConnector processing and the EA's order request separate. Broker acceptance, the deal and the position are further events. MetaQuotes distinguishes orders, deals and positions, while PineConnector's setup test checks the broker trade after processing.[4][5]
The fraction in a mathematical model is not evidence that the receiving account loses that exact fraction on each trade. Reconcile accepted volume, the initial stop and realised outcomes before treating a simulation as representative of that execution path.
Frequently asked questions
What is risk of ruin in trading?
Risk of ruin is the probability of reaching a specified loss boundary under stated assumptions. The boundary might be zero capital, a fixed capital floor or a drawdown from a running peak. A meaningful probability also states the horizon, position-sizing rule and trade-outcome model. Different definitions can produce very different answers.
What is the risk of ruin formula?
For independent equal-payoff trades with a fixed cash stake, win probability p above one half and capital of n stakes, the probability of ever reaching zero is [(1 − p) ÷ p]n. Without a favourable probability, eventual ruin is certain in that model. A finite target, variable payoffs or fixed-fraction sizing requires a different calculation.
How does the risk of ruin calculator work?
This calculator simulates independent wins and losses while sizing each loss as a fraction of current equity. It counts runs whose drawdown from a running peak reaches the selected threshold within the specified trade count. Identical inputs produce identical seeded results. The percentage is conditional on the simplified model, not a measured probability for a trading account.
Can a strategy with positive expectancy still reach ruin?
Yes. Positive expectancy describes an average outcome under a distribution; it does not prevent a sequence of losses from reaching a boundary. In this page's illustrative simulation, expectancy is +0.20R while 6.85% of 2,000 modelled paths breach a 20% drawdown within 200 trades at the specified 1% loss fraction.
Does fixed-fraction sizing make risk of ruin zero?
Only exact zero capital is unreachable in a finite number of ideal losses that each remove less than all current equity. An account can still breach a nonzero capital floor or a drawdown boundary. Real losses can exceed the modelled fraction, and broker limits can prevent further trading before equity reaches zero.
Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account and no code was compiled.
Related reading
- Trading metrics: the complete library
- Monte Carlo simulation and its assumptions
- Position sizing: fixed cash and fixed fractions
- Losing streak probability
- Kelly criterion and the limits of growth-based sizing
Sources
- Karl Sigman, Columbia University – Gambler's Ruin Problem (PDF), accessed 25 September 2026.
- TradingView – Pine Script v6 User Manual: Strategies, accessed 25 September 2026.
- PineConnector – Syntax: Loss-Based Sizing, accessed 25 September 2026.
- MetaQuotes – Basic Principles: Orders, Deals and Positions, accessed 25 September 2026.
- PineConnector – Test Your Setup, accessed 25 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.