Volatility Drag OscillatorVolatility Drag Oscillator — what is holding exposure costing you, and what does leverage do to it?
Compound growth is g = μ − σ²/2; under leverage, g(L) = L·μ − L²·σ²/2. Return scales with L, drag scales
with L² — which is the whole reason leverage does not raise your probability of success. Volatility is
estimable in hundreds of bars; drift needs decades. So this tool measures only the knowable half:
- DRAG = σ²/2 annualised (Yang-Zhang by default; Close-to-close / Parkinson / Garman-Klass /
Rogers-Satchell selectable to see estimator disagreement = gap-risk information), EWMA-smoothed and
ranked into a percentile so you know if today is a cheap or expensive time to hold.
- DRAG DECOMPOSITION — realised drag split into its exact cumulant pieces: variance (σ²/2) + skew +
excess-kurtosis, shown as "σ² · skw · tail" in %/yr. A fat-tail warning tells you HOW MUCH of your
drag is tails, not just that they exist — and it compares realised drag to its own Gaussian part, so
it can't be fooled by estimator choice.
- LEVERAGE CURVE — drag at 1×/2×/3×, plus break-even L_be = 2μ/σ² and Kelly = μ/σ², shown ONLY as
conditionals on an edge YOU enter. The script never estimates drift, and says why.
READ IT how you like: a familiar 0-100 percentile OSCILLATOR in the pane (cheap<20, expensive>80,
midline 50, like an RSI of holding-cost), or the absolute drag %/yr line. On price, a heat-RIBBON and
green/red regime triangles show cheap→expensive to hold — VOLATILITY regime, direction-agnostic. A red
marker means "expensive, size down", never "go short".
No directional claim and no backtest — there is nothing here to fit. Descriptive risk context, not advice.
Leverage magnifies losses; this shows one cost of it, not all risks. インジケーター

Kelly Criterion CurveThe 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:
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 インジケーター

Risk Management Calculator [tradeviZion]Risk Management Calculator - Script Description
📖 Overview
The Risk Management Calculator helps you find the optimal risk per trade based on your strategy's win rate, risk-to-reward ratio, and your tolerance for drawdowns and blowout risk. Instead of guessing a fixed 1–2%, it uses established formulas (Edge, Kelly criterion, and Risk of Ruin) to suggest a risk % that balances growth with survival.
Designed for swing traders, day traders, and systematic traders who want to size positions mathematically rather than by rule of thumb.
One risk % does not fit all. Your edge and tolerance for consecutive losses determine the best risk per trade.
Edge & Kelly - Computes your strategy edge and Full/Half/Quarter Kelly fractions
Risk of Ruin - Shows blowout probability at 1% to 10% risk, or solves for max risk given your target RoR
Consecutive Losses - Probability P(k) and drawdown at k losses for your chosen k values
Consecutive Losses Cone - Visual pane with P(k) and DD curves (2%, 3%, 5%, Rec, Max DD), k marker (vertical line + dot), best risk % for your selected k. Labels on curves; hover for tooltips. Optional legend in table.
---
⚙️ How It Works
⚪ Edge
Your edge is the expected value per unit risked. Positive edge means the strategy is profitable in expectation.
Edge = winRate × R:R − lossRate
Example: 30% win rate, 1:3 R:R → Edge = 0.30×3 − 0.70 = 0.20 (positive expectancy).
⚪ Risk of Ruin
The probability of losing your entire account. The formula uses your edge and risk fraction:
RoR ≈ ((1 − edge) / (1 + edge))^(1 / r)
where r is risk per trade. Assumes a long series of independent bets with stable edge. Lower risk per trade reduces RoR. Doubling risk increases RoR more than linearly. Approximation; may break down with skewed returns or finite horizons.
⚪ Kelly Criterion
The Kelly fraction maximizes long-run geometric growth. Full Kelly is often too aggressive; Half or Quarter Kelly is commonly used.
Full Kelly = (R:R × winRate − lossRate) / R:R
⚪ Consecutive Losses
Probability of k losses in a row:
P(k) = (1 − winRate)^k
Drawdown after k losses:
DD(k) = 1 − (1 − risk)^k
⚪ Best Risk
In Solve mode, the script finds the maximum risk % such that RoR ≤ your target. The Consecutive Losses Cone also computes a best risk % that keeps drawdown at your selected k within your Cone Max DD % limit, and uses the stricter of the two.
---
🎯 How to Use
Add the indicator to your chart (any symbol; it uses inputs only)
Enter your Account Capital , Win Rate % , and Risk-to-Reward Ratio from your backtest or live stats
Choose Mode : Solve for max risk % to get recommended risk, or Show RoR for given risk % to analyze a specific risk level
Review the Summary (Edge, Kelly, Recommended risk, Risk amount) and RoR Comparison table
Check the Consecutive Losses section to see P(k) and drawdown at your k values
Use the Probability Cone to visualize curves and the best risk % for your Cone Risk Marker k and Cone Max DD % . Hover cone labels for tooltips. Enable Cone Legend for a table legend.
---
⚙️ Settings
Core Parameters
Account Capital - Your trading capital. Used to show risk amount in dollars (e.g., 2% = $200 on $10,000).
Win Rate % - Percentage of winning trades (e.g., 30 = 30% winners, 70% losers).
Risk-to-Reward Ratio - Profit per unit risk (e.g., 3 = 1:3 R:R).
Target RoR % - Maximum acceptable Risk of Ruin. Lower = safer. Used when Mode is Solve for max risk % .
Target RoR Mode
Mode - Solve for max risk % : finds max risk within Target RoR. Show RoR for given risk % : shows RoR at Reference Risk %.
Reference Risk % - Risk % to analyze when Mode is Show RoR .
Consecutive Losses
k₁ to k₅ - Number of consecutive losses to analyze. Example: k₁=5 shows P(5) and drawdown at 5 losses in a row.
Table Settings
Color Theme - Dark, Light, Ocean Blue, Forest Green, etc.
Table Text Size - Tiny, Small, Normal, Large.
Tables Position - Left, Middle, or Right. All three tables stack vertically: Risk Management Calculator (top), Consecutive Losses Cone (middle), Consecutive Losses (bottom).
Display
Summary - Edge, Kelly, Recommended risk, Risk amount.
RoR Comparison - RoR at 1%, 2%, 3%, 5%, 7%, 10%.
Consecutive Losses - P(k) and DD table for k₁–k₅.
Probability Cone - P(k) and DD curves in a separate pane.
Cone Max k - Max consecutive losses on cone x-axis (20–100).
Cone Risk Marker k - k value highlighted with vertical line and dot.
Cone Max DD % - Max acceptable drawdown at marker k. Best risk respects this limit.
Cone Legend - Optional legend in the cone table (P(k) curve, DD curves, Rec%, best risk, k marker). Hover chart labels for the same info.
P(k) Color, DD Color, DD Rec% Color - Colors for cone curves. DD Rec% also used for best risk curve when RoR-limited (green); theme color when DD-limited.
---
⚠️ Disclaimer
This indicator is for educational and informational purposes only . It does not constitute investment advice. Past performance and backtested statistics do not guarantee future results. The RoR formula is an approximation and may not hold under skewed returns or finite horizons. Always do your own research and consider consulting a qualified financial advisor before trading.
インジケーター

Jensen's Inequality + Kelly LeverageThis 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+E )
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 - 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 インジケーター

Kelly Optimal Leverage IndicatorThe Kelly Optimal Leverage Indicator mathematically applies Kelly Criterion to determine optimal position sizing based on market conditions.
This indicator helps traders answer the critical question: "How much capital should I allocate to this trade?"
Note that "optimal position sizing" does not equal the position sizing that you should have. The Optima position sizing given by the indicator is based on historical data and cannot predict a crash, in which case, high leverage could be devastating.
Originally developed for gambling scenarios with known probabilities, the Kelly formula has been adapted here for financial markets to dynamically calculate the optimal leverage ratio that maximizes long-term capital growth while managing risk.
Key Features
Kelly Position Sizing: Uses historical returns and volatility to calculate mathematically optimal position sizes
Multiple Risk Profiles: Displays Full Kelly (aggressive), 3/4 Kelly (moderate), 1/2 Kelly (conservative), and 1/4 Kelly (very conservative) leverage levels
Volatility Adjustment: Automatically recommends appropriate Kelly fraction based on current market volatility
Return Smoothing: Option to use log returns and smoothed calculations for more stable signals
Comprehensive Table: Displays key metrics including annualized return, volatility, and recommended exposure levels
How to Use
Interpret the Lines: Each colored line represents a different Kelly fraction (risk tolerance level). When above zero, positive exposure is suggested; when below zero, reduce exposure. Note that this is based on historical returns. I personally like to increase my exposure during market downturns, but this is hard to illustrate in the indicator.
Monitor the Table: The information panel provides precise leverage recommendations and exposure guidance based on current market conditions.
Follow Recommended Position: Use the "Recommended Position" guidance in the table to determine appropriate exposure level.
Select Your Risk Profile: Conservative traders should follow the Half Kelly or Quarter Kelly lines, while more aggressive traders might consider the Three-Quarter or Full Kelly lines.
Adjust with Volatility: During high volatility periods, consider using more conservative Kelly fractions as recommended by the indicator.
Mathematical Foundation
The indicator calculates the optimal leverage (f*) using the formula:
f* = μ/σ²
Where:
μ is the annualized expected return
σ² is the annualized variance of returns
This approach balances potential gains against risk of ruin, offering a scientific framework for position sizing that maximizes long-term growth rate.
Notes
The Full Kelly is theoretically optimal for maximizing long-term growth but can experience significant drawdowns. You should almost never use full kelly.
Most practitioners use fractional Kelly strategies (1/2 or 1/4 Kelly) to reduce volatility while capturing most of the growth benefits
This indicator works best on daily timeframes but can be applied to any timeframe
Negative Kelly values suggest reducing or eliminating market exposure
The indicator should be used as part of a complete trading system, not in isolation
Enjoy the indicator! :)
P.S. If you are really geeky about the Kelly Criterion, I recommend the book The Kelly Capital Growth Investment Criterion by Edward O. Thorp and others.
インジケーター

FunctionKellyCriterionLibrary "FunctionKellyCriterion"
Kelly criterion methods.
the kelly criterion helps with the decision of how much one should invest in
a asset as long as you know the odds and expected return of said asset.
simplified(win_p, rr)
simplified version of the kelly criterion formula.
Parameters:
win_p : float, probability of winning.
rr : float, reward to risk rate.
Returns: float, optimal fraction to risk.
usage:
simplified(0.55, 1.0)
partial(win_p, loss_p, win_rr, loss_rr)
general form of the kelly criterion formula.
Parameters:
win_p : float, probability of the investment returns a positive outcome.
loss_p : float, probability of the investment returns a negative outcome.
win_rr : float, reward on a positive outcome.
loss_rr : float, reward on a negative outcome.
Returns: float, optimal fraction to risk.
usage:
partial(0.6, 0.4, 0.6, 0.1)
from_returns(returns)
Calculate the fraction to invest from a array of returns.
Parameters:
returns : array trade/asset/strategy returns.
Returns: float, optimal fraction to risk.
usage:
from_returns(array.from(0.1,0.2,0.1,-0.1,-0.05,0.05))
final_f(fraction, max_expected_loss)
Final fraction, eg. if fraction is 0.2 and expected max loss is 10%
then you should size your position as 0.2/0.1=2 (leverage, 200% position size).
Parameters:
fraction : float, aproximate percent fraction invested.
max_expected_loss : float, maximum expected percent on a loss (ex 10% = 0.1).
Returns: float, final fraction to invest.
usage:
final_f(0.2, 0.5)
hpr(fraction, trade, biggest_loss)
Holding Period Return function
Parameters:
fraction : float, aproximate percent fraction invested.
trade : float, profit or loss in a trade.
biggest_loss : float, value of the biggest loss on record.
Returns: float, multiplier of effect on equity so that a win of 5% is 1.05 and loss of 5% is 0.95.
usage:
hpr(fraction=0.05, trade=0.1, biggest_loss=-0.2)
twr(returns, rr, eps)
Terminal Wealth Relative, returns a multiplier that can be applied
to the initial capital that leadds to the final balance.
Parameters:
returns : array, list of trade returns.
rr : float , reward to risk rate.
eps : float , minimum resolution to void zero division.
Returns: float, optimal fraction to invest.
usage:
twr(returns=array.from(0.1,-0.2,0.3), rr=0.6)
ghpr(returns, rr, eps)
Geometric mean Holding Period Return, represents the average multiple made on the stake.
Parameters:
returns : array, list of trade returns.
rr : float , reward to risk rate.
eps : float , minimum resolution to void zero division.
Returns: float, multiplier of effect on equity so that a win of 5% is 1.05 and loss of 5% is 0.95.
usage:
ghpr(returns=array.from(0.1,-0.2,0.3), rr=0.6)
run_coin_simulation(fraction, initial_capital, n_series, n_periods)
run multiple coin flipping (binary outcome) simulations.
Parameters:
fraction : float, fraction of capital to bet.
initial_capital : float, capital at the start of simulation.
n_series : int , number of simulation series.
n_periods : int , number of periods in each simulation series.
Returns: matrix(n_series, n_periods), matrix with simulation results per row.
usage:
run_coin_simulation(fraction=0.1)
run_asset_simulation(returns, fraction, initial_capital)
run a simulation over provided returns.
Parameters:
returns : array, trade, asset or strategy percent returns.
fraction : float , fraction of capital to bet.
initial_capital : float , capital at the start of simulation.
Returns: array, array with simulation results.
usage:
run_asset_simulation(returns=array.from(0.1,-0.2,0.-3,0.4), fraction=0.1)
strategy_win_probability()
calculate strategy() current probability of positive outcome in a trade.
strategy_avg_won()
calculate strategy() current average won on a trade with positive outcome.
strategy_avg_loss()
calculate strategy() current average lost on a trade with negative outcome. ライブラリ
