OPEN-SOURCE SCRIPT
Kelly Criterion Curve

The Kelly Criterion Curve indicator gives you the leverage/return tradeoff by displaying a bell curve with growth and leverage. This indicator shows where you are on the risk curve depending your allocation/leverage used and the optimal leverage to use in any asset.
What Does It Show?
The indicator plots the Kelly growth function:
g(f) = μ·f - 0.5·σ²·f²
Where:
The curve peaks at the Optimal Kelly leverage (full Kelly) and then declines, showing that:
The curve is dynamically divided into zones based on your asset's return profile:
Position Markers
Settings for Kelly Calculation
How to Use
IMPORTANT
The indicator is based on past returns and volatility. It CANNOT predict:
If you use Optimal Kelly and suddenly there's a crash, you are toasted.
Remember leverage amplifies gains and losses
The Kelly Criterion was developed by John L. Kelly Jr. in 1956 for information theory and later adapted for gambling (card counting for example, pioneered by Edward O. Thorp), and investing.
Optimal Leverage:
f* = μ / σ²
Expected Growth Function:
g(f) = μ·f - 0.5·σ²·f²
This is a quadratic function that forms the bell curve you see on the chart.
This indicator pairs perfectly with my other indicators:
Kelly Optimal Leverage Indicator
Jensen's Inequality + Kelly Leverage
Multi-Leverage VAR/VaG Indicator
For deeper insights on Kelly Criterion and optimal leverage:
Read my article: Unlock the Power of Monte Carlo
Read these papers:
Alpha Generation and Risk Smoothing using Managed Volatility
Leverage for the Long Run - A Systematic Approach to Managing Risk and Magnifying Returns in Stocks
Trading with leverage involves substantial risk of loss.
The Kelly Criterion provides a theoretical framework - actual trading requires additional risk management, market analysis, and psychological discipline.
Some examples of using the Kelly Criterion Curve:
Russel 2000, last 500 days Kelly curve

Here's you can see that the optimal sizing over the last 500 days would have been around 1.7x leverage and that full Kelly is 3.4x leverage.
While Russel 2000 returned 16%, full Kelly would have returned 27.8%, and more that full Kelly (3.4x leverage) would lower the returns.
Berkshire Hathaway, last 1000 days Kelly curve

BRK stock optimal Kelly (full Kelly) is 2.5x for the last 1000 trading days. To reduce volatility, one could use 1/2 Kelly which is 1.25x leverage.
Bitcoin, last 2000 trading days Kelly curve

Very interestingly, the indicator tells us not to leverage Bitcoin. Even a 2x leverage can lead to ruin given its volatility, and in fact, in 2025 many traders got liquidated while leveraging Bitcoin by 2x.
Let me know if you have questions, suggestions and comments.
- Henrique Centieiro
What Does It Show?
The indicator plots the Kelly growth function:
g(f) = μ·f - 0.5·σ²·f²
Where:
- g(f) = Expected growth rate at leverage f
- μ = Annualized return
- σ = Annualized volatility
- f = Leverage multiplier
The curve peaks at the Optimal Kelly leverage (full Kelly) and then declines, showing that:
- Too little leverage = underutilized capital
- Too much leverage = volatility drag destroys returns
The curve is dynamically divided into zones based on your asset's return profile:
- Underinvesting (Green) - Too conservative, underutilized capital
- Optimal Sizing (Teal) - Sweet spot for position sizing
- High Risk (Yellow) - Diminishing returns, high volatility drag
- Never Logical (Red) - Risk outweighs reward
- Suicidal (Black) - Negative expected returns
Position Markers
- ★ Kelly Optimal (Green/Red) - Maximum long-term log growth leverage
- ½ Kelly (Yellow) - Conservative sizing (recommended most times)
Settings for Kelly Calculation
- Lookback Period - Historical data window for calculations (default: 252 = 1 year)
- Annual Trading Days - For annualization (default: 252)
- Use Log Returns - More accurate for compounding (recommended: ON)
- Curve Smoothness (20-200) - Number of points on curve (default: 100)
- Maximum Leverage Display (2-10x) - X-axis range
- Show Short Positions - Display negative leverage for short strategies. Note the chart is not fully optimized for shorts.
- Show Optimal Kelly Marker - Mark optimal leverage on curve
- Show Half Kelly Marker - Mark conservative leverage
How to Use
- Look at Optimal Kelly - This is the theoretical maximum for the period analyzed
- Use Half Kelly for conservative sizing
- Check which risk zone your position falls into
- If your leverage is in the High Risk zone → Consider reducing
- If you're in Never Logical or Suicidal → I wish you good luck because you will need a lot
- If you're in Underinvesting → You may be too conservative
IMPORTANT
The indicator is based on past returns and volatility. It CANNOT predict:
- Market crashes
- Regime changes
- Black swan events
If you use Optimal Kelly and suddenly there's a crash, you are toasted.
- Full Kelly maximizes long-term growth but can experience large drawdowns
- Most traders use ¼ to ½ Kelly for risk management
- You should almost never use full Kelly, unless you are extremely confident
Remember leverage amplifies gains and losses
- Notice how Max Growth isn't simply Ann. Return × Leverage
- The formula accounts for volatility drag (the cost of using leverage)
- Higher volatility = lower optimal leverage
The Kelly Criterion was developed by John L. Kelly Jr. in 1956 for information theory and later adapted for gambling (card counting for example, pioneered by Edward O. Thorp), and investing.
Optimal Leverage:
f* = μ / σ²
Expected Growth Function:
g(f) = μ·f - 0.5·σ²·f²
This is a quadratic function that forms the bell curve you see on the chart.
This indicator pairs perfectly with my other indicators:
Kelly Optimal Leverage Indicator
Jensen's Inequality + Kelly Leverage
Multi-Leverage VAR/VaG Indicator
For deeper insights on Kelly Criterion and optimal leverage:
Read my article: Unlock the Power of Monte Carlo
Read these papers:
Alpha Generation and Risk Smoothing using Managed Volatility
Leverage for the Long Run - A Systematic Approach to Managing Risk and Magnifying Returns in Stocks
Trading with leverage involves substantial risk of loss.
The Kelly Criterion provides a theoretical framework - actual trading requires additional risk management, market analysis, and psychological discipline.
Some examples of using the Kelly Criterion Curve:
Russel 2000, last 500 days Kelly curve
Here's you can see that the optimal sizing over the last 500 days would have been around 1.7x leverage and that full Kelly is 3.4x leverage.
While Russel 2000 returned 16%, full Kelly would have returned 27.8%, and more that full Kelly (3.4x leverage) would lower the returns.
Berkshire Hathaway, last 1000 days Kelly curve
BRK stock optimal Kelly (full Kelly) is 2.5x for the last 1000 trading days. To reduce volatility, one could use 1/2 Kelly which is 1.25x leverage.
Bitcoin, last 2000 trading days Kelly curve
Very interestingly, the indicator tells us not to leverage Bitcoin. Even a 2x leverage can lead to ruin given its volatility, and in fact, in 2025 many traders got liquidated while leveraging Bitcoin by 2x.
Let me know if you have questions, suggestions and comments.
- Henrique Centieiro
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Hedge Fund Manager at Maverick Capital | Wealth Educator | 20+ yrs investing | Stocks, ETFs & Crypto alerts | Join Henrique Wealth Academy for trade alerts & indicators → skool.com/be-limitless/
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Hedge Fund Manager at Maverick Capital | Wealth Educator | 20+ yrs investing | Stocks, ETFs & Crypto alerts | Join Henrique Wealth Academy for trade alerts & indicators → skool.com/be-limitless/
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.