Uptrick: Quantum Divergence OscillatorIntroduction
Uptrick: Quantum Divergence Oscillator is a dual-mode oscillator designed to study market stretch, momentum imbalance, and potential reversal development. Instead of relying on a single oscillator formula, the script offers two analytical engines inside one indicator: a price-deviation oscillator and a standardized momentum oscillator.
Classic mode evaluates how far price has stretched away from an adaptive baseline estimate. Z-RSI mode evaluates how far RSI has stretched away from its own recent statistical distribution. These two approaches measure different types of imbalance and allow users to study reversal conditions from both price displacement and momentum behavior.
Beyond the oscillator itself, the script includes a trend overlay, histogram state coloring, overlay signal labels, background tinting during extreme conditions, chart coloring modes, a multi-timeframe dashboard, and alert conditions. The goal is to provide a structured workflow for monitoring exhaustion, reversal development, and broader directional context.
Overview
The indicator operates in two selectable modes.
Classic mode is a price-deviation oscillator that measures how far price has moved away from a smoothed equilibrium estimate. Z-RSI mode transforms RSI into a standardized Z-Score framework so that momentum strength or weakness is interpreted relative to its own recent behavior.
Both engines share the same surrounding framework: signal labeling, trend context, visual feedback through histogram and background coloring, multi-timeframe summaries, and alert support. The script therefore functions as both an oscillator study and a contextual analysis tool.
Originality and design logic
The script’s design is based on combining two complementary analytical models rather than modifying a single oscillator formula.
Classic mode focuses on price equilibrium. It builds an adaptive estimate of price using a Nadaraya-Watson kernel approach and then refines that estimate with KNN smoothing. The oscillator measures the deviation between price and that estimate and expresses it relative to current volatility using ATR normalization. This allows the oscillator to highlight situations where price is unusually stretched relative to a smoothed local value.
Z-RSI mode focuses on momentum distribution. Instead of using RSI with fixed thresholds such as 70 and 30, it evaluates whether RSI is statistically unusual compared with its recent behavior. Converting RSI to a Z-Score allows momentum extremes to be interpreted relative to their distribution rather than fixed levels.
These two engines therefore analyze different dimensions of market imbalance. Classic mode evaluates displacement from equilibrium, while Z-RSI evaluates momentum deviation from its statistical norm.
Classic mode engine
Classic mode begins with the selected price source and processes it through an adaptive smoothing workflow.
ATR is first calculated to determine the current volatility regime. The ATR percentile rank inside the Vol Rank Window modifies the effective lookback period and kernel bandwidth using the Adaptation Strength parameter. This allows the smoothing system to expand or contract according to volatility conditions.
A Nadaraya-Watson estimate is calculated from the source series. The estimate is then refined using a KNN smoothing pass that weights similar historical values in order to reduce residual noise. The deviation between price and the smoothed estimate is then measured and normalized by ATR so the oscillator reflects relative stretch rather than raw price distance.
The normalized series is smoothed with an EMA and scaled using a percentile-based reference window so that values typically remain within a range near −100 to +100. This produces the final Classic oscillator.
Dynamic overbought and oversold bands
Classic mode uses dynamic bands instead of fixed levels.
The base levels are +40 and −40. These levels expand or contract depending on the ATR percentile rank. When volatility increases the bands widen, and when volatility decreases they tighten. This helps maintain a consistent interpretation of stretch across changing market conditions.
The oscillator is considered overbought above the upper band and oversold below the lower band. Signals are generated when the oscillator exits these extreme zones rather than when it first enters them.
Regular divergence detection
Classic mode also includes pivot-based regular divergence detection.
The script confirms oscillator pivots using separate Left Bars and Right Bars settings. When a pivot low or pivot high is confirmed, the script compares it with prior pivots stored within the Max Lookback window.
A bullish regular divergence occurs when price forms a lower low while the oscillator forms a higher low. A bearish regular divergence occurs when price forms a higher high while the oscillator forms a lower high.
Because pivots require confirmation, divergence signals appear only after the configured Right Bars confirmation period.
An Occurrence Filter allows users to restrict signals to the first, second, third, fourth, or fifth divergence in a sequence, or to display all qualifying divergences.
Z-RSI mode
Z-RSI mode evaluates momentum using a standardized framework.
The script first calculates RSI from the selected source. It then calculates the mean and standard deviation of RSI over the Z-Score Lookback period. The current RSI value is converted into a Z-Score and smoothed with an EMA.
The resulting histogram shows how unusual the current RSI value is relative to its recent distribution.
Interpretation is organized around two sets of thresholds:
• ±1 represent signal thresholds
• ±2 represent statistical extremes
Values near zero indicate that RSI is close to its average behavior. Values above +2 or below −2 represent unusually strong or unusually weak momentum relative to recent conditions.
Signal events in this mode are threshold-based rather than pivot-based. Signals occur when the Z-Score transitions back through the configured threshold levels.
Histogram coloring and panel logic
Both modes use histogram coloring to communicate both oscillator position and short-term direction.
In Classic mode the histogram remains neutral between the dynamic bands. When the oscillator moves into overbought or oversold zones the color reflects both the zone and the slope of the oscillator.
In Z-RSI mode the same principle is applied to the ±2 extreme thresholds.
The oscillator panel can display additional visual elements including the zero line, dynamic thresholds, shaded zones, and a trend meter when Full Setup is enabled.
Trend overlay and trend meter
The script includes a trend overlay plotted directly on the price chart.
The trend line is created by smoothing the selected source using an EMA and then applying an additional smoothing pass. The slope of this line defines the current trend direction.
A vertical gradient fill is drawn between price and the trend line so that the distance between them is visually emphasized.
A horizontal trend meter is also displayed at the top of the oscillator panel. This band changes color according to the trend state and provides a persistent visual context while reading the oscillator.
Overlay signals and controls
Signal labels can be plotted directly on the price chart.
In Classic mode signals can be generated from divergence detection, overbought/oversold exits, or both. In Z-RSI mode signals are generated from threshold transitions defined by the ±1 and ±2 levels.
Labels are plotted on the bar where the signal is confirmed. For divergence events, the price level used for placement corresponds to the confirmed pivot price.
Direction filters allow signals to be restricted to bullish events, bearish events, or both directions.
Bar and candle coloring
The script provides three chart coloring modes.
Signal mode colors bars according to the most recent bullish or bearish signal state. Trend mode colors bars according to the current trend direction. Heat mode creates a continuous gradient derived from the oscillator value so that stronger positive values appear increasingly bearish and stronger negative values appear increasingly bullish.
These colors are applied both to bars and to candles plotted by the script.
Background tinting
The script can tint the chart background when extreme conditions occur.
In Classic mode the tint corresponds to the dynamic overbought and oversold zones. In Z-RSI mode the tint corresponds to the ±2 statistical extremes.
This feature provides an additional visual cue when the oscillator reaches conditions associated with strong momentum imbalance.
Dashboard and multi-timeframe context
The script includes a dashboard that summarizes the current state of the indicator.
The table displays the active mode, oscillator value, zone state, signal state, trend direction, and chart configuration. It also reports volatility or Z-Score statistics depending on the selected mode.
A multi-timeframe section summarizes trend direction and oscillator bias for the current timeframe together with 1H, 4H, and 1D data. These higher-timeframe values are derived from the Classic engine variables so the dashboard maintains consistent context even when Z-RSI mode is active.
Alerts
Alert conditions are included for bullish divergence, bearish divergence, oversold exits, overbought exits, and composite bullish or bearish signals. These alerts allow the script to be integrated into an active monitoring workflow.
Summary
Uptrick: Quantum Divergence Oscillator is a dual-engine oscillator designed to analyze market stretch through both price displacement and momentum distribution.
Classic mode studies how far price has moved away from an adaptive equilibrium estimate using kernel smoothing, KNN refinement, ATR normalization, and dynamic volatility-adjusted bands. Z-RSI mode evaluates momentum extremes by converting RSI into a Z-Score framework and interpreting signals relative to statistical thresholds.
Supporting features include a trend overlay with gradient fill, histogram state visualization, overlay signal labels, background extreme highlighting, flexible chart coloring modes, multi-timeframe dashboard context, and alert conditions.
Together these components provide a structured environment for studying exhaustion, momentum imbalance, and potential reversal development.
Disclaimer
This script is provided for educational and analytical purposes only. It does not constitute financial advice or a recommendation to buy or sell any asset. Trading involves risk, and past performance does not guarantee future results.
Indicador Pine Script®






















