TradingView backtesting guides

Kelly criterion trading calculator

Kelly sizing maximizes expected log growth under a specified return model. This free calculator uses two outcomes: win a fixed multiple of the amount risked, or lose that amount. Compare full and fractional Kelly, then test how uncertain inputs change the result.

The output is a model risk fraction, not a stock allocation recommendation. Trading returns, costs and correlated positions can invalidate these assumptions.

Calculate binary Kelly risk

Input Mode

%

Probability of winning each bet (0-100%)

Average win amount divided by average loss amount

%

100% = Full Kelly; 50% = Half Kelly; 0% = hold cash. The default is an illustration, not a recommendation.

Trading Edge
Positive modeled edge(37.50% expectancy per dollar risked)

Amounts below are capital at risk in the modeled loss, not position notional. Costs, gaps and correlated trades are not modeled separately.

Full Kelly model risk
25.00%
Full Kelly: $2,500.0050% Kelly: $1,250.00
Bankroll: $10,000.00 · Win Rate: 55% · W/L Ratio: 1.50

Kelly Criterion Metrics

Metric
Value
Raw Kelly %
Before the zero-risk floor
25.00%
Full Kelly %
Feasible model risk fraction
25.00%
50% Kelly
Fractional Kelly bet
12.50%
Full Kelly Risk Amount
Full Kelly dollar amount
$2,500.00
Fractional Bet Size
50% Kelly dollar amount
$1,250.00
Expected Value
Per $1 wagered
$0.3750
Growth Rate
Expected log growth per bet
4.5693%
Edge
Expected return percentage
37.50%
Log-growth Doubling Count
ln(2) / G, not a waiting-time forecast
16 bets

The binary Kelly formula and its units

Let p be win probability, q = 1 - p, and b the net winning profit per dollar risked. A win multiplies wealth by 1 + fb; a loss multiplies it by 1 - f. For this model, maximizing expected log growth gives:

G(f) = p ln(1 + fb) + (1 - p) ln(1 - f)

f* = p - (1 - p) / b

Risk fraction = max(0, f*)

Fractional risk = chosen multiplier × max(0, f*)

The feasible choice here is to place the specified bet or hold cash, without borrowing. A negative raw Kelly value therefore produces zero risk. The break-even probability is 1 / (1 + b): at b = 1.5 it is 40%. Positive historical expectancy alone does not establish a future edge.

The binary solution and its cash alternative follow the two-outcome derivation in Busseti, Ryu and Boyd, Risk-Constrained Kelly Gambling, section 2.3.

A calculation you can reproduce

Enter a 55% win rate, a 1.5 win/loss ratio and a $10,000 bankroll. The arithmetic is 0.55 - 0.45 / 1.5 = 0.25. Full Kelly risks 25%, or $2,500; a 50% Kelly multiplier risks 12.5%, or $1,250. These are illustrations under the stated model, not proposed account risk limits.

MultiplierAccount at riskRisk dollarsExpected log growth G
25% Kelly6.25%$6250.02024
50% Kelly12.50%$1,2500.03443
100% Kelly25.00%$2,5000.04569
200% Kelly50.00%$5,000-0.00413

Each growth value uses the formula above, with natural logarithms, per bet. Double Kelly is not universally zero growth: in this example it is negative. Half Kelly is about 75.3% of full Kelly log growth here, not an exact 75% rule. Ten consecutive modeled losses leave 0.75^10 = 5.63% of starting capital at full Kelly, versus 0.875^10 = 26.31% at half Kelly. Fractional sizing still permits severe losses.

Estimation error changes the sizing decision

Keep b = 1.5 and lower the estimated win rate from 55% to 45%: full Kelly falls from 25% to 8.33%. At 40% it is zero; at 35% raw Kelly is -8.33%, so the feasible amount remains zero. A 10 percentage point probability error changes full Kelly by 16.67 percentage points because its slope with respect to p is 1 + 1/b.

If the true win probability were 45%, risking the earlier 25% estimate would give G = 0.45 ln(1.375) + 0.55 ln(0.75) = -0.01492 per bet. A seemingly favorable input can therefore produce a losing growth rate when the estimate is wrong. Reducing the fraction limits exposure but does not prove the edge exists.

  1. Use trades from a consistent rule set and period. Include commissions, spreads, financing and slippage in the payoff estimates.
  2. Check lower win-rate and payoff scenarios, then compare on held-out trades without retuning to that test set.
  3. Record gaps and unusually large losses. Do not treat average loss as a guaranteed maximum loss.
  4. Review overlapping positions together. Separate Kelly calculations do not account for trades that lose at the same time.

Variable returns need a different model

Advanced mode still compresses trades into two outcomes using average win divided by average loss. Real returns may have many outcomes or a continuous distribution. The general objective is to maximize E[ln(1 + fR)] over feasible f, where R is the net return on the chosen exposure. Replacing outcomes by their averages generally changes that objective.

For example, returns of +10% or -5% with equal probability have a 2:1 payoff ratio. Binary risk Kelly is 25%. Converting that risk into exposure gives 0.25 / 0.05 = 5 times capital, which requires leverage. An unlevered allocation must remain within its own constraints. This calculator does not solve those constraints or a correlated portfolio.

Risk-Constrained Kelly Gambling, sections 2 and 3 formulates the broader return-distribution problem and distinguishes growth maximization from drawdown control. Fractional Kelly scales exposure; it does not impose a specified maximum drawdown.

Read the calculator output within its limits

Basic mode requires a positive payoff ratio. Advanced mode requires positive average win and loss amounts. Bankroll must be positive, win rate must be between 0% and 100%, and the Kelly multiplier must be between 0% and 100%. Empty, nonfinite or out-of-range inputs produce an error instead of a result.

At 0% win probability the model chooses zero. At 100% it chooses all capital for a positive payoff, because it assumes losses are impossible. A streak of wins cannot establish that assumption. The Kelly curve excludes a 100% stake because any nonzero loss probability makes expected log growth negative infinite there.

The growth tab shows a deterministic log-growth illustration, W₀ exp(nG), with constant inputs. It is not expected dollar wealth, a backtest or a sampled equity path. It cannot display actual drawdowns. The doubling figure is ln(2) / G, not an expected waiting time or deadline.

For the next calculation, use the position size calculator to convert a separately chosen risk budget and stop distance into units. A stop order does not guarantee its execution price. For methodology, return to TradingView backtesting guides.

Source checked October 17, 2026. Numerical examples are direct calculations under the stated binary model. Educational information only, not investment advice. Historical results and model outputs do not guarantee future returns.

Kelly sizing questions

What does the Kelly formula calculate?

For a binary payoff, f = p - (1 - p) / b maximizes expected log growth, where p is win probability and b is net profit per dollar lost on a losing bet. This calculator floors negative sizing at zero because it models placing the specified bet or holding cash.

Is Kelly percentage the share of my account invested in a stock?

Here it is the fraction lost in the modeled losing outcome. It is not automatically the notional allocation. A stock position with a stop requires a separate conversion from risk dollars to units; gaps, slippage, costs and leverage can make the actual loss larger.

Does Advanced mode solve Kelly for variable trading returns?

No. Advanced mode divides average win by average loss to form the same two-outcome approximation. A general return distribution requires maximizing E[ln(1 + fR)] with costs and feasible wealth constraints. Averages do not preserve the expected logarithm.

Does half Kelly always deliver 75% of full Kelly growth?

No. That ratio is an approximation in particular models, not an identity for every binary payoff. At p = 55% and b = 1.5, full Kelly has expected log growth 0.04569 per bet; half Kelly has 0.03443. Neither number forecasts a realized return.

What does a negative Kelly result mean?

A negative raw result means the specified bet has negative modeled expectancy. The calculator displays that raw value but sets the feasible risk amount to zero. It does not recommend reversing or shorting the trade; the opposite trade has different costs and payoffs.

What happens at 0% or 100% win probability?

At 0%, the model chooses zero risk. At 100%, with a positive payoff, the binary model with no borrowing chooses 100% risk. These are mathematical endpoints. A sample with no observed losses does not establish certainty, and the 100% output is not a recommendation.

Are the growth lines a backtest or Monte Carlo simulation?

No. They plot initial bankroll multiplied by exp(nG), using constant expected log growth G. They contain no sampled wins, losses, drawdowns or confidence interval. The double-Kelly line is capped at 100% of bankroll; risking 100% with a nonzero loss probability gives negative infinite expected log growth.

How should I handle an uncertain win rate?

Compare plausible lower win rates and payoff ratios, including costs, and validate on held-out trades. Correlated observations and a changing market reduce what a historical estimate can establish. No fixed trade count or Kelly fraction makes the estimate reliable.

Start with the trades behind your estimates

Use Trading Journal to record and review your trading sample. Keep simulated and live trades separate. The journal does not turn a historical win rate into a known future probability.

Once you choose explicit risk limits, use the Pine Script AI Coding Agent to draft the rules, then inspect and backtest the code in TradingView. This calculator does not place orders.