OPEN-SOURCE SCRIPT
Jensen's Inequality + Kelly Leverage

This indicator reveals how volatility drag erodes returns through Jensen's Inequality and calculates scientifically optimal leverage levels using the Kelly Criterion. It answers the question: "At what leverage does volatility drag destroy more returns than leverage creates?"
I have created other indicators related to optimal leverage, Kelly Criterion and Jensen's inequality which you can fin in the comments.
Understand Jensen's Inequality
Jensen's Inequality is a theorem stating that for concave functions (like logarithms or sad face), the expected value of the function is less than the function of the expected value:
E[log(1+R)] ≤ log(1+E[R])
What this means for investors is that your realized geometric return (what you actually earn through compounding) is always less than your arithmetic average return. This gap is called volatility drag.
The drag formula: Drag = L² × σ² / 2
The quadratic term (L²) is crucial because if you double your leverage, quadruple your drag. This helps us to understand how much leverage we can take during volatile times (for example leveraged ETFs).
Understand Kelly Criterion
The Kelly Criterion, developed by John Kelly at Bell Labs in 1956, calculates the optimal bet size (or leverage) that maximizes long-term logarithmic growth of wealth:
Kelly = (μ - r_f) / σ²
Where:
Kelly tells you the exact leverage that balances return amplification against volatility drag to maximize your long-term compound growth rate.
Why I Combine Both?
Jensen's Inequality explains why leverage has, after a certain point, diminishing returns and eventually becomes destructive. Volatility drag grows faster than return amplification. The Kelly Criterion tells you exactly where the optimal point is before drag overwhelms your gains.
Together, they provide:
The Math Behind It
Geometric return formula:
r_geometric = L × r_arithmetic - (L² × σ²) / 2
This shows the tug-of-war between leverage amplification (L × r_arithmetic) and drag (L² × σ²/2).
Maximum survivable leverage:
L_max = 2 × r_arithmetic / σ²
At this point, drag completely cancels out returns (geometric return = 0). Beyond this, you're guaranteed to lose money over time.
How To Read The Chart
The Table Breakdown
Jensen's Inequality (1x & 2x): Side-by-side comparison demonstrating:
Optimal Leverage: Kelly calculations with fractional variants

Practical Insights
Settings
As you should know by now, leverage is a double-edged sword. This indicator shows you exactly where the edge cuts both ways, helping you find the sweet spot between aggressive growth and mathematical ruin.
Let me know if you have any suggestions.
- Henrique Centieiro
I have created other indicators related to optimal leverage, Kelly Criterion and Jensen's inequality which you can fin in the comments.
Understand Jensen's Inequality
Jensen's Inequality is a theorem stating that for concave functions (like logarithms or sad face), the expected value of the function is less than the function of the expected value:
E[log(1+R)] ≤ log(1+E[R])
What this means for investors is that your realized geometric return (what you actually earn through compounding) is always less than your arithmetic average return. This gap is called volatility drag.
The drag formula: Drag = L² × σ² / 2
The quadratic term (L²) is crucial because if you double your leverage, quadruple your drag. This helps us to understand how much leverage we can take during volatile times (for example leveraged ETFs).
Understand Kelly Criterion
The Kelly Criterion, developed by John Kelly at Bell Labs in 1956, calculates the optimal bet size (or leverage) that maximizes long-term logarithmic growth of wealth:
Kelly = (μ - r_f) / σ²
Where:
- μ = arithmetic return (expected return)
- r_f = risk-free rate
- σ² = variance (volatility squared)
Kelly tells you the exact leverage that balances return amplification against volatility drag to maximize your long-term compound growth rate.
Why I Combine Both?
Jensen's Inequality explains why leverage has, after a certain point, diminishing returns and eventually becomes destructive. Volatility drag grows faster than return amplification. The Kelly Criterion tells you exactly where the optimal point is before drag overwhelms your gains.
Together, they provide:
- Jensen: How much drag you're experiencing
- Kelly: What leverage maximizes your growth
- Both: Where leverage becomes dangerous
The Math Behind It
Geometric return formula:
r_geometric = L × r_arithmetic - (L² × σ²) / 2
This shows the tug-of-war between leverage amplification (L × r_arithmetic) and drag (L² × σ²/2).
Maximum survivable leverage:
L_max = 2 × r_arithmetic / σ²
At this point, drag completely cancels out returns (geometric return = 0). Beyond this, you're guaranteed to lose money over time.
How To Read The Chart
- Y-axis: Geometric returns (%) - what you actually earn after accounting for drag
- Colored lines: Expected returns at different leverage levels over time
- Green line (1.0x): Unleveraged baseline
- Orange/Red lines (2x/3x): Higher leverage scenarios
- Blue circles: Kelly optimal leverage level
- Red label at zero: Max survivable leverage (breakeven point)
The Table Breakdown
Jensen's Inequality (1x & 2x): Side-by-side comparison demonstrating:
- How drag scales quadratically (1.99% → 7.96% when leverage doubles)
- The verification that L×E[R] - Drag = Realized Return
Optimal Leverage: Kelly calculations with fractional variants
- Full Kelly: Theoretically optimal but aggressive
- 0.75x, 0.5x, 0.25x Kelly: Conservative risk management
- Sharpe Optimal: Maximizes risk-adjusted returns
- Max Leverage: Your "game over" threshold
- Leverage Scenarios: Detailed comparison of 1x, 2x, 3x positions showing geometric returns, drag costs, and Sharpe ratios
Practical Insights
- Low volatility assets: Higher Kelly → can handle more leverage safely
- High volatility assets (crypto for example): Lower Kelly → even 2x can be destructive
- Current market regime matters: The indicator adapts to changing volatility conditions
- Fractional Kelly is wisdom: Full Kelly assumes perfect parameter estimates (which we never have)
Settings
- Risk-free rate: Auto-fetches FRED:DGS3MO (3-month T-Bills) or manual override
- Log returns: Enabled by default for mathematically accurate compounding
- Display options: Toggle curve/table, adjust positioning and font sizes
- Lookback period: Adjustable from 50 to 1500 bars
As you should know by now, leverage is a double-edged sword. This indicator shows you exactly where the edge cuts both ways, helping you find the sweet spot between aggressive growth and mathematical ruin.
Let me know if you have any suggestions.
- Henrique Centieiro
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
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/
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
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/
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。