OPEN-SOURCE SCRIPT
Vol-Target Trend Engine

WHAT IT DOES
VTTE is a leveraged-ETF allocation engine. It holds a 3x index ETF (built for TQQQ/UPRO) only during favorable regimes, and lets realized volatility set the position size. There is no entry signal being predicted anywhere in the script - the edge is the risk-allocation policy itself, which is why the system has almost no tunable surface to overfit.
HOW IT WORKS
1) REGIME GATE - the position exists only while price trades above its 200-day SMA. Leveraged ETFs suffer volatility decay fastest in downtrends; the gate removes the catastrophic left tail instead of trying to predict it. Below the SMA the system is 100% cash.
2) VOLATILITY TARGETING - exposure = min(100%, target vol / realized vol), using 20-day realized volatility annualized against a 45% target. This is the same architecture vol-control indices and risk-parity desks run: position size shrinks mechanically as volatility expands, which front-runs drawdowns because volatility clusters.
3) REBALANCING - weekly, inside a 10% tolerance band to keep turnover and commission drag low, with an immediate de-risk override when held exposure runs 1.5x over target. Regime flips act immediately.
BACKTEST PROPERTIES (fully disclosed)
0.05% commission per side, 1 tick slippage, fills on close, $10,000 initial. TQQQ daily Feb 2010 - Aug 2026: +3,862% realized net, profit factor 3.33, 155 rebalance events (67.7% profitable), max drawdown 41.9%. Buy-and-hold TQQQ returned more over the same window (+20,107%) but with multiple drawdowns beyond 80%; the S&P 500 returned roughly +630%. The honest comparison is CAGR ~26% at roughly half of buy-and-hold's worst drawdown.
WHAT WAS TESTED AND REJECTED
A faster variant (5-day vol estimate, de-risk any day of the week) was tested and REJECTED with numbers: turnover more than doubled, the system repeatedly sold volatility spikes at their lows and re-bought higher, net return fell from +3,862% to +2,158%, profit factor 3.33 to 1.98, and max drawdown got WORSE (41.9% to 49.6%). Slow rebalancing is a feature, not a limitation.
INPUTS
Realized vol lookback (20d), target annualized vol (45%), regime SMA length (200), rebalance band (10%), fast de-risk toggle.
LIMITATIONS
Single instrument, single history, in-sample. TQQQ's listed history begins in 2010 - a mostly secular-bull window; the regime gate carries the 2020 and 2022 stress periods, but the configuration has not been walk-forward validated yet. Treat every figure as an upper bound on expectancy, not a forecast. Not financial advice.
VTTE is a leveraged-ETF allocation engine. It holds a 3x index ETF (built for TQQQ/UPRO) only during favorable regimes, and lets realized volatility set the position size. There is no entry signal being predicted anywhere in the script - the edge is the risk-allocation policy itself, which is why the system has almost no tunable surface to overfit.
HOW IT WORKS
1) REGIME GATE - the position exists only while price trades above its 200-day SMA. Leveraged ETFs suffer volatility decay fastest in downtrends; the gate removes the catastrophic left tail instead of trying to predict it. Below the SMA the system is 100% cash.
2) VOLATILITY TARGETING - exposure = min(100%, target vol / realized vol), using 20-day realized volatility annualized against a 45% target. This is the same architecture vol-control indices and risk-parity desks run: position size shrinks mechanically as volatility expands, which front-runs drawdowns because volatility clusters.
3) REBALANCING - weekly, inside a 10% tolerance band to keep turnover and commission drag low, with an immediate de-risk override when held exposure runs 1.5x over target. Regime flips act immediately.
BACKTEST PROPERTIES (fully disclosed)
0.05% commission per side, 1 tick slippage, fills on close, $10,000 initial. TQQQ daily Feb 2010 - Aug 2026: +3,862% realized net, profit factor 3.33, 155 rebalance events (67.7% profitable), max drawdown 41.9%. Buy-and-hold TQQQ returned more over the same window (+20,107%) but with multiple drawdowns beyond 80%; the S&P 500 returned roughly +630%. The honest comparison is CAGR ~26% at roughly half of buy-and-hold's worst drawdown.
WHAT WAS TESTED AND REJECTED
A faster variant (5-day vol estimate, de-risk any day of the week) was tested and REJECTED with numbers: turnover more than doubled, the system repeatedly sold volatility spikes at their lows and re-bought higher, net return fell from +3,862% to +2,158%, profit factor 3.33 to 1.98, and max drawdown got WORSE (41.9% to 49.6%). Slow rebalancing is a feature, not a limitation.
INPUTS
Realized vol lookback (20d), target annualized vol (45%), regime SMA length (200), rebalance band (10%), fast de-risk toggle.
LIMITATIONS
Single instrument, single history, in-sample. TQQQ's listed history begins in 2010 - a mostly secular-bull window; the regime gate carries the 2020 and 2022 stress periods, but the configuration has not been walk-forward validated yet. Treat every figure as an upper bound on expectancy, not a forecast. Not financial advice.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.