Trend Safety Switch — Strategy by oridahari

By KivancOzbilgic

Performance Metrics

Description

Trend Safety Switch is a long-only SuperTrend strategy with a simple risk check.It tries to stay in good trends and step aside when the market looks risky. It never goes short.HOW TO READ IT- Green line under price = up trend, the strategy is invested.- Red line above price = down trend.- Grey line = the trend is up, but the market is risk-off, so the strategy stays out.- Orange background = risk-off. Enough warnings are on, and the strategy holds 0%.- BUY -> 100% label: the strategy invests the full position.- SELL 70% (keep 30%) label: the trend turned down, but the market is still healthy, so part of the position is kept.- SELL ALL label: the strategy exits everything.- "Now: ..." at the right edge shows the current position, trend and risk state, with the reason.- The table compares the strategy with buy-and-hold on the same bars.WHAT IS NEW COMPARED WITH THE ORIGINALClassic SuperTrend is all-in or all-out on every flip. That causes many whipsaws in choppy markets and full exits from healthy uptrends. This version keeps the original band logic and defaults and adds:1. A risk check with three warnings (each can be turned off): VIX ranking over 252 bars is 80 or higher, close is below the 200-bar average, and the drop from the 1-year high is deeper than 15%. Risk-off = 2 or more warnings (adjustable).2. Partial selling: on a down-flip in a healthy market, it keeps 30% (adjustable) instead of selling everything. In risk-off it holds 0%.3. A chop filter: a new full entry needs ADX of 15 or more.4. Plain-word labels, a live status label and alerts for each label and for risk-off.5. A stats table: return, max drawdown, time invested and closed trades, strategy vs buy-and-hold.SETTINGS- SuperTrend: ATR 10, multiplier 3.0, source hl2 (original defaults).- Risk check: VIX symbol CBOE:VIX, 200-bar average, 15% drawdown limit, 2 warnings needed.- Keep 30% on a down-flip (set 0 for classic all-in/all-out). ADX 14, minimum 15.- Backtest start: 2000.STRATEGY PROPERTIES USED FOR THE REPORT- Initial capital 10,000. Long only. Position size 0%, 30% or 100% of equity. No leverage.- Commission 0.02% per order, slippage 2 ticks.- Orders fill at the next bar's open.- Daily ETFs trade rarely, so the test runs from 2000 to get more than 100 trades.HONEST RESULTSIn my own test on daily QQQ and SPY (2010-2026, with costs), the strategy earned much less than buy-and-hold on both. On QQQ it had a smaller max drawdown than buy-and-hold and did better than plain SuperTrend. On SPY it did not beat plain SuperTrend, and it fell about as much as buy-and-hold in 2022. Treat it as a drawdown-control tool, not a way to beat the index. Results change a lot with the symbol, period and settings.NOTES AND LIMITS- Made for daily charts of liquid US indexes and ETFs. The VIX warning is US-specific, so turn it off for other markets.- SuperTrend lags by design. Gaps can make fills worse than the signal price.CREDITSuperTrend is a classic ATR indicator by Olivier Seban. The band and trend-flip code is based on the open-source "SuperTrend" by KivancOzbilgic, who credits everget for the signal style. Thank you. This is a Pine v6 strategy rewrite with new position logic and filters.DISCLAIMERFor education only. This is not financial advice. Past results and backtests do not guarantee future results.Release Notesv1.1- Code cleanup: the ATR is now computed on every bar on its own line. Signals, orders and results are the same as before.- Checked: the stats table counts from the backtest start date across the full history. The strategy stays long-only and never opens a short.- Reminder: past backtest results only. They are not a forecast and not financial advice.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView