OPEN-SOURCE SCRIPT
Volatility Managed Kelly Leverage

The Volatility Managed Kelly Leverage (VMKL) indicator is a tool that dynamically adjusts position sizing based on forecasted market volatility. It helps you to optimize leverage exposure by systematically reducing risk during high volatility periods and increasing exposure when markets are calm.
VMKL adapts in real-time to changing market conditions, potentially generating alpha while smoothing volatility and reducing maximum drawdown.
This indicator implements the Optimal Volatility Plus Mean Strategy (OVPMS) from one of my favorite leverage papers:
"Alpha Generation and Risk Smoothing using Managed Volatility" by Tony Cooper (2010)
These are the key findings from the paper, which this indicator translates to real life:
The indicator calculates optimal leverage using a three-step process
1. Volatility Forecasting
Uses Exponential Weighted Moving Average (EWMA):
σ²(t) = λ·σ²(t-1) + (1-λ)·r²(t-1)
This predicts next-day volatility from recent price movements
2. Return Prediction
Expected Return = a × σ^(b+1)
Where:
The negative exponent means returns decrease as volatility increases - a well-documented market behaviour.
3. Optimal Leverage Calculation
Full Kelly Leverage = μ / σ²
Actual Leverage = Full Kelly × Kelly Fraction × Caps × Smoothing
The Kelly Criterion provides the theoretically optimal leverage, which is then reduced via:
The Core Insight: Volatility varies over time (volatility of volatility), and this variation is costly. By targeting consistent volatility through dynamic leverage:
The indicator calculates optimal leverage in real-time using EWMA volatility forecasting and Kelly Criterion mathematics, automatically detecting market regimes from CASH to VERY AGGRESSIVE and respective leverages. The statistics table shows Full Kelly leverage, Kelly Fraction leverage, forecasted volatility, predicted returns, and current regime.
Settings Guide
Please check the informational "i" in setting to get a lot more info.
You can also use preset configurations:
Conservative (Safe)
Kelly Fraction: 0.50
Max Leverage: 2.0x
Lambda: 0.97
Sensitivity: Enhanced
Moderate (Balanced) ⭐ DEFAULT
Kelly Fraction: 0.75
Max Leverage: 3.0x
Lambda: 0.94
Sensitivity: Enhanced
Aggressive (Maximum)
Kelly Fraction: 1.0
Max Leverage: 5.0x
Lambda: 0.90
Sensitivity: Standard
Paper Replication (Academic)
Kelly Fraction: 1.0
Max Leverage: 3.0x
Lambda: 0.94
Sensitivity: Standard
Adaptive: ON
Smoothing: 1
Remember: LEVERAGE MAGNIFIES BOTH GAINS AND LOSSES
Let me know if you have questions!
By Henrique Centieiro
VMKL adapts in real-time to changing market conditions, potentially generating alpha while smoothing volatility and reducing maximum drawdown.
This indicator implements the Optimal Volatility Plus Mean Strategy (OVPMS) from one of my favorite leverage papers:
"Alpha Generation and Risk Smoothing using Managed Volatility" by Tony Cooper (2010)
These are the key findings from the paper, which this indicator translates to real life:
- Volatility is predictable while returns are not
- Dynamic leverage based on volatility forecasts can generate significant excess returns
- The strategy reduces volatility of volatility (vovo), kurtosis, and maximum drawdown
- Tested on 125+ years of market data across multiple global indices
- The OVPMS strategy (translated into this indicator) returned 12.6% annual return vs 7.0% for buy-and-hold, with the same volatility as the underlying index. Outstanding.
The indicator calculates optimal leverage using a three-step process
1. Volatility Forecasting
Uses Exponential Weighted Moving Average (EWMA):
σ²(t) = λ·σ²(t-1) + (1-λ)·r²(t-1)
This predicts next-day volatility from recent price movements
2. Return Prediction
Expected Return = a × σ^(b+1)
Where:
- a = Power coefficient (baseline return, default: 0.10)
- b = Power exponent (return-volatility relationship, default: -1.76 for SPY)
- σ = Forecasted volatility
The negative exponent means returns decrease as volatility increases - a well-documented market behaviour.
3. Optimal Leverage Calculation
Full Kelly Leverage = μ / σ²
Actual Leverage = Full Kelly × Kelly Fraction × Caps × Smoothing
The Kelly Criterion provides the theoretically optimal leverage, which is then reduced via:
- Kelly Fraction: Safety margin (default 75% = three-quarter Kelly)
- Leverage Caps: Hard maximum and minimum limits
- Smoothing: SMA to reduce rebalancing frequency
The Core Insight: Volatility varies over time (volatility of volatility), and this variation is costly. By targeting consistent volatility through dynamic leverage:
- Reduces volatility drag - Compounding works better with stable volatility
- Reduces drawdowns - Automatically deleverages before crashes
- Reduces kurtosis - Fewer extreme return events
- Generates alpha - Exploits the return-volatility relationship
The indicator calculates optimal leverage in real-time using EWMA volatility forecasting and Kelly Criterion mathematics, automatically detecting market regimes from CASH to VERY AGGRESSIVE and respective leverages. The statistics table shows Full Kelly leverage, Kelly Fraction leverage, forecasted volatility, predicted returns, and current regime.
Settings Guide
Please check the informational "i" in setting to get a lot more info.
You can also use preset configurations:
Conservative (Safe)
Kelly Fraction: 0.50
Max Leverage: 2.0x
Lambda: 0.97
Sensitivity: Enhanced
Moderate (Balanced) ⭐ DEFAULT
Kelly Fraction: 0.75
Max Leverage: 3.0x
Lambda: 0.94
Sensitivity: Enhanced
Aggressive (Maximum)
Kelly Fraction: 1.0
Max Leverage: 5.0x
Lambda: 0.90
Sensitivity: Standard
Paper Replication (Academic)
Kelly Fraction: 1.0
Max Leverage: 3.0x
Lambda: 0.94
Sensitivity: Standard
Adaptive: ON
Smoothing: 1
Remember: LEVERAGE MAGNIFIES BOTH GAINS AND LOSSES
Let me know if you have questions!
By Henrique Centieiro
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
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/
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
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/
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.