OPEN-SOURCE SCRIPT
Atualizado Spectre

SPECTRE - Precision Reversal Detection System
OVERVIEW
Spectre is a channel breakout indicator designed to identify high-probability reversal points by combining Donchian channel breaches with momentum confirmation. It generates BUY signals at oversold extremes and SELL signals at overbought extremes, filtered by trend strength to avoid low-conviction setups.
This indicator replaces the Regime Engine, which will continue to evolve independently as an experimental platform for testing new strategies and enhancements. Spectre was selected as the production replacement based on extensive backtesting across multiple assets and timeframes, which demonstrated superior win rates compared to alternative sell logic approaches (RSI-based exits outperformed CMO-based exits in 13 of 18 test configurations).
SIGNAL LOGIC
BUY CONDITIONS (all must be true):
Price touches or breaks below Donchian lower band
RSI is at or below oversold threshold (default: 35)
ADX confirms sufficient trend strength (default: ≥22)
BBWP confirms adequate volatility (default: ≥20%)
Cooldown period has elapsed since last buy
Cascade limit not reached
SELL CONDITIONS (all must be true):
Price touches or breaks above Donchian upper band
RSI is at or above overbought threshold (default: 70)
ADX confirms sufficient trend strength (default: ≥22)
BBWP confirms adequate volatility (default: ≥20%)
Cooldown period has elapsed since last sell
Cascade limit not reached
Price is not underwater (if protection enabled)
KEY FEATURES
NON-REPAINTING DONCHIAN CHANNELS
Uses previous bar's high/low extremes to prevent signal repainting. What you see in history is what you would have seen in real-time.
MULTI-FACTOR CONFIRMATION
Signals require agreement between price action (Donchian), momentum (RSI), and trend strength (ADX) to filter out low-quality setups.
VOLATILITY FILTER (BBWP)
Bollinger Band Width Percentile measures current volatility relative to historical norms. Low BBWP indicates compressed ranges where breakouts are less reliable - signals are blocked until volatility returns.
CASCADE PROTECTION
Limits consecutive signals in the same direction to prevent overexposure during extended trends. Resets when a signal fires in the opposite direction.
UNDERWATER PROTECTION (Unique to Spectre)
Tracks average entry price of recent buys and blocks sell signals when price has fallen significantly below this level. This prevents locking in large losses during drawdowns and allows positions to recover before exiting.
REGIME DETECTION
Visual background shading indicates current market regime based on Directional Indicator spread and On-Balance Volume trend. Green indicates bullish regime (+DI > -DI, OBV rising). Red indicates bearish regime (-DI > +DI, OBV falling). White/Gray indicates neutral or ranging conditions.
RECOMMENDED SETTINGS BY TIMEFRAME
For 5-minute charts, use RSI Buy 30-35, RSI Sell 70-75, ADX 20-24.
For 15-minute charts, use RSI Buy 30-35, RSI Sell 68-72, ADX 22-26.
For 30-minute charts (default), use RSI Buy 32-38, RSI Sell 68-72, ADX 22-26.
For 1-hour charts, use RSI Buy 35-40, RSI Sell 65-70, ADX 20-24.
For 4-hour charts, use RSI Buy 35-40, RSI Sell 65-70, ADX 18-22.
These are starting points - optimize for your specific assets.
INFO PANEL GUIDE
Regime shows current market bias (Bullish/Bearish/Neutral). RSI shows current value with buy/sell threshold status. ADX shows trend strength categorized as Weak (<15), Range (15-24), Trend (24-34), or Strong (>34). BBWP shows volatility percentile with a warning symbol when below minimum. Donchian shows price position relative to channel bands. Avg Buy shows average entry price and underwater status. Cascade shows current consecutive signal counts versus limits.
USAGE TIPS
Works best in ranging or mean-reverting markets
Reduce RSI thresholds in strong trends (tighter = fewer signals)
Increase ADX minimum in choppy markets to filter noise
Enable underwater protection for swing trading, disable for scalping
Use regime background to contextualize signals (buy in green, sell in red)
Combine with support/resistance levels for additional confirmation
OVERVIEW
Spectre is a channel breakout indicator designed to identify high-probability reversal points by combining Donchian channel breaches with momentum confirmation. It generates BUY signals at oversold extremes and SELL signals at overbought extremes, filtered by trend strength to avoid low-conviction setups.
This indicator replaces the Regime Engine, which will continue to evolve independently as an experimental platform for testing new strategies and enhancements. Spectre was selected as the production replacement based on extensive backtesting across multiple assets and timeframes, which demonstrated superior win rates compared to alternative sell logic approaches (RSI-based exits outperformed CMO-based exits in 13 of 18 test configurations).
SIGNAL LOGIC
BUY CONDITIONS (all must be true):
Price touches or breaks below Donchian lower band
RSI is at or below oversold threshold (default: 35)
ADX confirms sufficient trend strength (default: ≥22)
BBWP confirms adequate volatility (default: ≥20%)
Cooldown period has elapsed since last buy
Cascade limit not reached
SELL CONDITIONS (all must be true):
Price touches or breaks above Donchian upper band
RSI is at or above overbought threshold (default: 70)
ADX confirms sufficient trend strength (default: ≥22)
BBWP confirms adequate volatility (default: ≥20%)
Cooldown period has elapsed since last sell
Cascade limit not reached
Price is not underwater (if protection enabled)
KEY FEATURES
NON-REPAINTING DONCHIAN CHANNELS
Uses previous bar's high/low extremes to prevent signal repainting. What you see in history is what you would have seen in real-time.
MULTI-FACTOR CONFIRMATION
Signals require agreement between price action (Donchian), momentum (RSI), and trend strength (ADX) to filter out low-quality setups.
VOLATILITY FILTER (BBWP)
Bollinger Band Width Percentile measures current volatility relative to historical norms. Low BBWP indicates compressed ranges where breakouts are less reliable - signals are blocked until volatility returns.
CASCADE PROTECTION
Limits consecutive signals in the same direction to prevent overexposure during extended trends. Resets when a signal fires in the opposite direction.
UNDERWATER PROTECTION (Unique to Spectre)
Tracks average entry price of recent buys and blocks sell signals when price has fallen significantly below this level. This prevents locking in large losses during drawdowns and allows positions to recover before exiting.
REGIME DETECTION
Visual background shading indicates current market regime based on Directional Indicator spread and On-Balance Volume trend. Green indicates bullish regime (+DI > -DI, OBV rising). Red indicates bearish regime (-DI > +DI, OBV falling). White/Gray indicates neutral or ranging conditions.
RECOMMENDED SETTINGS BY TIMEFRAME
For 5-minute charts, use RSI Buy 30-35, RSI Sell 70-75, ADX 20-24.
For 15-minute charts, use RSI Buy 30-35, RSI Sell 68-72, ADX 22-26.
For 30-minute charts (default), use RSI Buy 32-38, RSI Sell 68-72, ADX 22-26.
For 1-hour charts, use RSI Buy 35-40, RSI Sell 65-70, ADX 20-24.
For 4-hour charts, use RSI Buy 35-40, RSI Sell 65-70, ADX 18-22.
These are starting points - optimize for your specific assets.
INFO PANEL GUIDE
Regime shows current market bias (Bullish/Bearish/Neutral). RSI shows current value with buy/sell threshold status. ADX shows trend strength categorized as Weak (<15), Range (15-24), Trend (24-34), or Strong (>34). BBWP shows volatility percentile with a warning symbol when below minimum. Donchian shows price position relative to channel bands. Avg Buy shows average entry price and underwater status. Cascade shows current consecutive signal counts versus limits.
USAGE TIPS
Works best in ranging or mean-reverting markets
Reduce RSI thresholds in strong trends (tighter = fewer signals)
Increase ADX minimum in choppy markets to filter noise
Enable underwater protection for swing trading, disable for scalping
Use regime background to contextualize signals (buy in green, sell in red)
Combine with support/resistance levels for additional confirmation
Notas de Lançamento
Changed BBWP parameters to favor 5 and 15 min trades. Configurable in settingsScript de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.