Hybrid Pivot SuperTrend and Range DetectorHybrid Pivot SuperTrend and Range Detector: A Complete Market Phase Solution
Introduction: The Purpose of the Indicator
Financial markets inherently operate in two distinct phases: trending and ranging. Traditional technical indicators often excel in one environment but fail drastically in the other. Trend-following tools generate false signals during market consolidations, while oscillators and mean-reversion tools get overwhelmed during explosive breakouts.
The Hybrid Pivot SuperTrend and Range Detector was engineered to solve this exact dilemma. It is an advanced, dual-engine technical analysis tool designed to dynamically adapt to the current market state. By merging a sophisticated consolidation detector with a structural trend-following system, this script identifies high-probability trading opportunities regardless of whether the market is moving sideways or accelerating into a new trend. Its primary purpose is to provide traders with clear, actionable intelligence, allowing them to trade support and resistance bounces during flat markets, and seamlessly transition into trend-following mode the moment a breakout occurs.
Core Mechanics: How It Detects Buy and Sell Signals
This indicator is built upon a complex interaction between market volatility, structural pivot points, and price action behavior. It divides its logic into distinct engines that work in tandem:
1. The Dynamic Range Detector
The foundation of the ranging logic utilizes a Simple Moving Average (SMA) paired with an Average True Range (ATR) multiplier. The script scans historical price action for consecutive bars where the price remains tightly coiled within the SMA plus/minus the ATR threshold.
Once this consolidation is mathematically confirmed, the script draws a visual boundary box.
Range Buy (R-Buy): Triggered when the price dips into the lower boundary (Support) and shows rejection, suggesting a bounce back to the mean.
Range Sell (R-Sell): Triggered when the price pushes into the upper boundary (Resistance) and is rejected downward.
To eliminate visual noise, the script features a smart signal-locking mechanism. Once a valid trend breakout occurs, it disables all "R-Signals" until a brand-new consolidation box is formed, preventing traders from catching falling knives.
2. The Pivot Point SuperTrend
Unlike the traditional SuperTrend that relies on a simple median price, this script calculates its baseline using structural Pivot Highs and Pivot Lows. This creates a weighted, more structurally sound center line. By applying an ATR multiplier (Factor) to this pivot center line, it forms dynamic upper and lower trailing stop bands. When the price crosses these bands, the trend direction flips.
3. Breakout and Trend Signals (T-Signals)
The trend system issues signals when momentum shifts:
Trend Buy (T-Buy): Initiated when the SuperTrend flips bullish, or an existing bullish trend coincides with a clean breakout above the Range Detector's upper box.
Trend Sell (T-Sell): Initiated when the SuperTrend flips bearish, or a bearish trend coincides with a breakdown below the Range box.
4. The Smart Retest & Pullback Engine
One of the most advanced features of this script is its order-execution delay system. Breakouts are notoriously prone to "fake-outs." When a T-Buy or T-Sell is detected, the indicator can be set to hold the signal in a pending state. It calculates a target retracement level (measured in standard price ticks or percentages). The final signal is only plotted when the price pulls back to retest this breakout level. If the market is too aggressive and runs away without retesting, a built-in safety timer (max_wait_bars) ensures the signal fires anyway, guaranteeing you do not miss a massive parabolic move.
Practical Application: Setup and Ideal Markets
Because of its highly modular settings, this indicator is incredibly versatile, but it requires tuning based on the asset class and timeframe you are trading.
Recommended Settings:
For Intraday Traders (15m to 1H): Keep the Range Width relatively tight (around 0.8 to 1.5) to catch micro-consolidations. Set the SuperTrend ATR Factor to 2.0 or 3.0 to react quickly to intraday momentum shifts. The Retest mode should be set to "Ticks" to capitalize on precise order block retests.
For Swing Traders (4H to Daily): Increase the Minimum Range Length to ensure you are only identifying major multi-day consolidations. A wider SuperTrend ATR Factor (3.0 to 4.0) is recommended to avoid getting chopped out by daily market noise.
Suitable Markets:
Forex: Currency pairs like EUR/USD or GBP/JPY are highly mean-reverting and respect structural ranges well, making the Range Detector exceptionally profitable during the Asian or early London sessions.
Cryptocurrency: Bitcoin and altcoins are notorious for long periods of low-volatility chopping followed by violent breakouts. The Hybrid system shines here, especially using the Retest Engine to avoid the initial breakout manipulation (liquidity grabs) common in crypto.
Indices: Assets like the S&P 500 or NASDAQ tend to have a strong upward drift. Traders can use the SuperTrend component to trail stop-losses effectively while using the Range Detector to buy minor pullbacks during the broader uptrend.
Attribution: Pivot Point SuperTrend
A special thanks and full credit must be given to the talented TradingView developer, LonesomeTheblue, for the original concept and foundational code of the Pivot Point SuperTrend. By innovatively utilizing structural Pivot Highs and Lows to calculate the baseline rather than the traditional median price, LonesomeTheblue created a significantly more robust trend-following tool. Their brilliant logic serves as the critical trend-detection engine within this hybrid script, and this adaptation builds directly upon their exceptional work.
Attribution: Range Detector
I would also like to express my sincere gratitude and attribute full credit to LuxAlgo for the foundational logic behind the Range Detector component. LuxAlgo’s original open-source script masterfully demonstrated how to mathematically identify market consolidations using a combination of a Simple Moving Average and ATR thresholds. Their elegant method for drawing dynamic support and resistance boxes provides the core ranging mechanics of this hybrid indicator, allowing it to expertly navigate sideways market conditions.
Penunjuk Pine Script®






















