OPEN-SOURCE SCRIPT

Multi-Leverage VAR/VaG Indicator

836
Here's why I developed this indicator: I love leverage but most people don't use leverage correctly. This indicator helps you understanding whether leverage is advantageous and how much should be used.
Standard VAR calculations assume linear scaling (2x leverage = 2x risk), which is wrong for leveraged ETFs. Also, most VaR indicators show risk without comparing it to potential reward. This one tells you how do you quantify whether current market conditions are friendly or hostile to leveraged positions?

To do this, we calculate both the downside risk (VAR), upside potential (VaG), and their relationship across different leverage levels.

PROBLEMS THIS INDICATOR SOLVES
THE LEVERAGE SCALING FALLACY
  • Problem: Traders assume 3x leverage means 3x the risk.
  • Reality: Due to volatility decay and daily rebalancing, leveraged ETFs don't scale linearly. A 3x ETF can lose MORE than 3x in high downside volatility markets or LESS than 3x during up trending markets.
  • Solution: This indicator simulates actual leveraged ETF mechanics by applying leverage to each daily return and compounding over your holding period.

THE REGIME BLINDNESS PROBLEM
  • Problem: Traders use the same leverage in all market conditions.
  • Reality: Trending, low-volatility markets favor leverage. Choppy, high-volatility markets penalize leverage through volatility drag.
  • Solution: The VaG/|VAR| ratio quantifies leverage efficiency. When the leverage VaG/|VAR| is higher than the 1x VaG/|VAR|, then leverage is friendly .

THE RISK-WITHOUT-CONTEXT PROBLEM
  • Problem: Knowing your maximum loss doesn't tell you if that risk is worth taking.
  • Reality: A -10% VAR might be acceptable if VaG is +30%, but terrible if VaG is only +8%.
  • Solution: I calculate both downside and upside at the same confidence level for complete risk/reward context.

HOW THIS INDICATOR IS USEFUL TO INVESTORS
  • Determine optimal leverage level for current market conditions
  • Identify when to scale up or reduce leveraged positions based on regime changes
  • Calculate dollar risk on any account size for proper position sizing
  • Understand true risk of leveraged ETFs beyond the "3x" label
  • Detect transitions between leverage-friendly and leverage-hostile regimes

CORE METHODOLOGY: Historical simulation with daily rebalancing
Unlike parametric VAR (assumes normal distribution) or Monte Carlo (generates synthetic scenarios), this uses historical simulation - what actually happened in the past.
  1. Calculate daily returns from closing prices
  2. Simulate leveraged ETF behavior with daily rebalancing - apply leverage to each daily return, compound over the holding period, and cap losses at -100% (ETFs can't go negative)
  3. Create a distribution by sliding the holding period window across the lookback period (252-day lookback with 21-day holding = 232 scenarios)
  4. Sort all outcomes and extract percentiles: VAR = lower tail (e.g., 5th percentile at 95% confidence), VaG = upper tail (e.g., 95th percentile)
  5. Calculate efficiency ratio: VaG / |VAR|

This tells you: for every dollar of downside risk, how many dollars of upside potential do you get?

HOW TO USE THIS INDICATOR
  • Lookback Period (default: 252 days) - Longer = more data but slower to adapt; Shorter = more responsive but less reliable
  • Holding Period (default: 21 days) - Match to your timeframe: 5-10 days (day traders), 21-42 days (swing traders), 63-126 days (position traders)
  • Confidence Level (default: 95%) - 90% for typical outcomes, 95% for balanced view, 99% for extreme tail risk
  • Leverage Levels (default: 1x, 2x, 3x) - Customize to your trading, supports decimals like 1.5x

INTERPRETING THE TABLE:
  • Lev = Leverage multiplier
  • VAR (%) = Maximum expected loss over holding period
  • VaG (%) = Minimum expected gain over holding period
  • VaG/|VAR| = Leverage efficiency ratio
  • VAR on $10k = Dollar loss on $10,000 position

EXAMPLE INTERPRETATION
snapshot
This QQQ chart demonstrates the indicator's power to identify leverage regimes.
Current metrics (table):
1x: VAR -3.21%, VaG +21.58%, Ratio 6.73
2x: VAR -6.79%, VaG +46.58%, Ratio 6.86
3x: VAR -10.71%, VaG +75.26%, Ratio 7.02
This means:
  • Ratios above 6.5 are outstanding - upside is nearly 7x the downside at all leverage levels
  • Backwardation pattern: the ratio IMPROVES with more leverage (6.73 → 7.02), indicating strong trending conditions favor higher leverage
  • VAR remains very manageable even at 3x (-10.71% on a 55-day hold)
  • At 3x leverage, you risk $1,071 to potentially gain $7,526 on $10k - exceptional risk/reward. And understanding risk/reward is one of the most important points here.

Trade smart. Manage risk. Know your regime.
And let me know if you have any questions or suggestions.
- Henrique Centieiro

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.