OPEN-SOURCE SCRIPT
Trend Catch STFR - whipsaw Reduced

### Summary of the Setup
This trading system combines **SuperTrend** (a trend-following indicator based on ATR for dynamic support/resistance), **Range Filter** (a smoothed median of the last 100 candles to identify price position relative to a baseline), and filters using **VIX Proxy** (a volatility measure: (14-period ATR / 14-period SMA of Close) × 100) and **ADX** (Average Directional Index for trend strength). It's designed for trend trading with volatility safeguards.
- **Entries**: Triggered only in "tradeable" markets (VIX Proxy ≥ 15 OR ADX ≥ 20) when SuperTrend aligns with direction (green for long, red for short), price crosses the Range Filter median accordingly, and you're not already in that position.
- **Exits**: Purely price-based—exit when SuperTrend flips or price crosses back over the Range Filter median. No forced exits from low volatility/trend.
- **No Trade Zone**: Blocks new entries if both VIX Proxy < 15 AND ADX < 20, but doesn't affect open positions.
- **Overall Goal**: Enter trends with confirmed strength/volatility, ride them via price action, and avoid ranging/choppy markets for new trades.
This creates a filtered trend-following strategy that prioritizes quality entries while letting winners run.
### Advantages
- **Reduces Noise in Entries**: The VIX Proxy and ADX filters ensure trades only in volatile or strongly trending conditions, avoiding low-momentum periods that often lead to false signals.
- **Lets Winners Run**: Exits based solely on price reversal (SuperTrend or Range Filter) allow positions to stay open during temporary lulls in volatility/trend, potentially capturing longer moves.
- **Simple and Balanced**: Combines trend (SuperTrend/ADX), range (Filter), and volatility (VIX Proxy) without overcomplicating—easy to backtest and adapt to assets like stocks, forex, or crypto.
- **Adaptable to Markets**: The "OR" logic for VIX/ADX provides flexibility (e.g., enters volatile sideways markets if ADX is low, or steady trends if VIX is low).
- **Risk Control**: Implicitly limits exposure by blocking entries in calm markets, which can preserve capital during uncertainty.
### Disadvantages
- **Whipsaws in Choppy Markets**: As you noted, SuperTrend can flip frequently in ranging conditions, leading to quick entries/exits and small losses, especially if the Range Filter isn't smoothing enough noise.
- **Missed Opportunities**: Strict filters (e.g., requiring VIX ≥ 15 or ADX ≥ 20) might skip early-stage trends or low-volatility grinds, reducing trade frequency and potential profits in quiet bull/bear markets.
- **Lagging Exits**: Relying only on price flips means you might hold losing trades longer if volatility drops without a clear reversal, increasing drawdowns.
- **Parameter Sensitivity**: Values like VIX 15, ADX 20, or Range Filter's 100-candle lookback need tuning per asset/timeframe; poor choices could amplify whipsaws or over-filter.
- **No Built-in Risk Management**: Lacks explicit stops/targets, so it relies on user-added rules (e.g., ATR-based stops), which could lead to oversized losses if not implemented.
### How to Use It
This system can be implemented in platforms like TradingView (via Pine Script), Python (e.g., with TA-Lib or Pandas), or MT4/5. Here's a step-by-step guide, assuming TradingView for simplicity—adapt as needed. (If coding in Python, use libraries like pandas_ta for indicators.)
1. **Set Up Indicators**:
- Add SuperTrend (default: ATR period 10, multiplier 3—adjust as suggested in prior tweaks).
- Create Range Filter: Use a 100-period SMA of (high + low)/2, smoothed (e.g., via EMA if desired).
- Calculate VIX Proxy: Custom script for (ATR(14) / SMA(close, 14)) * 100.
- Add ADX (period 14, standard).
2. **Define Rules in Code/Script**:
- **Long Entry**: If SuperTrend direction < 0 (green), close > RangeFilterMedian, (VIX Proxy ≥ 15 OR ADX ≥ 20), and not already long—buy on bar close.
- **Short Entry**: If SuperTrend direction > 0 (red), close < RangeFilterMedian, (VIX Proxy ≥ 15 OR ADX ≥ 20), and not already short—sell short.
- **Exit Long**: If in long and (SuperTrend > 0 OR close < RangeFilterMedian)—sell.
- **Exit Short**: If in short and (SuperTrend < 0 OR close > RangeFilterMedian)—cover.
- Monitor No Trade Zone visually (e.g., plot yellow background when VIX < 15 AND ADX < 20).
3. **Backtest and Optimize**:
- Use historical data on your asset (e.g., SPY on 1H chart).
- Test metrics: Win rate, profit factor, max drawdown. Adjust thresholds (e.g., ADX to 25) to reduce whipsaws.
- Forward-test on demo account to validate.
4. **Live Trading**:
- Apply to a chart, set alerts for entries/exits.
- Add risk rules: Position size 1-2% of capital, stop-loss at SuperTrend line.
- Monitor manually or automate via bots—avoid overtrading; use on trending assets.
For the adjustments I suggested earlier (e.g., ADX 25, 2-bar confirmation), integrate them into entries only—test one at a time to isolate improvements. If whipsaws persist, combine 2-3 tweaks.
This trading system combines **SuperTrend** (a trend-following indicator based on ATR for dynamic support/resistance), **Range Filter** (a smoothed median of the last 100 candles to identify price position relative to a baseline), and filters using **VIX Proxy** (a volatility measure: (14-period ATR / 14-period SMA of Close) × 100) and **ADX** (Average Directional Index for trend strength). It's designed for trend trading with volatility safeguards.
- **Entries**: Triggered only in "tradeable" markets (VIX Proxy ≥ 15 OR ADX ≥ 20) when SuperTrend aligns with direction (green for long, red for short), price crosses the Range Filter median accordingly, and you're not already in that position.
- **Exits**: Purely price-based—exit when SuperTrend flips or price crosses back over the Range Filter median. No forced exits from low volatility/trend.
- **No Trade Zone**: Blocks new entries if both VIX Proxy < 15 AND ADX < 20, but doesn't affect open positions.
- **Overall Goal**: Enter trends with confirmed strength/volatility, ride them via price action, and avoid ranging/choppy markets for new trades.
This creates a filtered trend-following strategy that prioritizes quality entries while letting winners run.
### Advantages
- **Reduces Noise in Entries**: The VIX Proxy and ADX filters ensure trades only in volatile or strongly trending conditions, avoiding low-momentum periods that often lead to false signals.
- **Lets Winners Run**: Exits based solely on price reversal (SuperTrend or Range Filter) allow positions to stay open during temporary lulls in volatility/trend, potentially capturing longer moves.
- **Simple and Balanced**: Combines trend (SuperTrend/ADX), range (Filter), and volatility (VIX Proxy) without overcomplicating—easy to backtest and adapt to assets like stocks, forex, or crypto.
- **Adaptable to Markets**: The "OR" logic for VIX/ADX provides flexibility (e.g., enters volatile sideways markets if ADX is low, or steady trends if VIX is low).
- **Risk Control**: Implicitly limits exposure by blocking entries in calm markets, which can preserve capital during uncertainty.
### Disadvantages
- **Whipsaws in Choppy Markets**: As you noted, SuperTrend can flip frequently in ranging conditions, leading to quick entries/exits and small losses, especially if the Range Filter isn't smoothing enough noise.
- **Missed Opportunities**: Strict filters (e.g., requiring VIX ≥ 15 or ADX ≥ 20) might skip early-stage trends or low-volatility grinds, reducing trade frequency and potential profits in quiet bull/bear markets.
- **Lagging Exits**: Relying only on price flips means you might hold losing trades longer if volatility drops without a clear reversal, increasing drawdowns.
- **Parameter Sensitivity**: Values like VIX 15, ADX 20, or Range Filter's 100-candle lookback need tuning per asset/timeframe; poor choices could amplify whipsaws or over-filter.
- **No Built-in Risk Management**: Lacks explicit stops/targets, so it relies on user-added rules (e.g., ATR-based stops), which could lead to oversized losses if not implemented.
### How to Use It
This system can be implemented in platforms like TradingView (via Pine Script), Python (e.g., with TA-Lib or Pandas), or MT4/5. Here's a step-by-step guide, assuming TradingView for simplicity—adapt as needed. (If coding in Python, use libraries like pandas_ta for indicators.)
1. **Set Up Indicators**:
- Add SuperTrend (default: ATR period 10, multiplier 3—adjust as suggested in prior tweaks).
- Create Range Filter: Use a 100-period SMA of (high + low)/2, smoothed (e.g., via EMA if desired).
- Calculate VIX Proxy: Custom script for (ATR(14) / SMA(close, 14)) * 100.
- Add ADX (period 14, standard).
2. **Define Rules in Code/Script**:
- **Long Entry**: If SuperTrend direction < 0 (green), close > RangeFilterMedian, (VIX Proxy ≥ 15 OR ADX ≥ 20), and not already long—buy on bar close.
- **Short Entry**: If SuperTrend direction > 0 (red), close < RangeFilterMedian, (VIX Proxy ≥ 15 OR ADX ≥ 20), and not already short—sell short.
- **Exit Long**: If in long and (SuperTrend > 0 OR close < RangeFilterMedian)—sell.
- **Exit Short**: If in short and (SuperTrend < 0 OR close > RangeFilterMedian)—cover.
- Monitor No Trade Zone visually (e.g., plot yellow background when VIX < 15 AND ADX < 20).
3. **Backtest and Optimize**:
- Use historical data on your asset (e.g., SPY on 1H chart).
- Test metrics: Win rate, profit factor, max drawdown. Adjust thresholds (e.g., ADX to 25) to reduce whipsaws.
- Forward-test on demo account to validate.
4. **Live Trading**:
- Apply to a chart, set alerts for entries/exits.
- Add risk rules: Position size 1-2% of capital, stop-loss at SuperTrend line.
- Monitor manually or automate via bots—avoid overtrading; use on trending assets.
For the adjustments I suggested earlier (e.g., ADX 25, 2-bar confirmation), integrate them into entries only—test one at a time to isolate improvements. If whipsaws persist, combine 2-3 tweaks.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.