OPEN-SOURCE SCRIPT

Cadence Refracted Oscillator [JOAT]

1 955
Cadence Refracted Oscillator [JOAT]

Introduction

The Cadence Refracted Oscillator is an open-source multi-layer momentum analysis tool built in Pine Script v6. It combines three distinct momentum methodologies — Spectral-Filtered RSI, Stochastic Momentum Index (SMI), and Cumulative Volume Delta (CVD) divergence detection — into a single composite oscillator displayed in a separate pane below the chart. The indicator produces a blended momentum reading (0-100), a gradient histogram, a signal line with crossover detection, Z-score extreme markers, and Wyckoff absorption alerts. It is designed for traders who want a deeper, noise-reduced view of momentum that goes beyond what a standard RSI or stochastic can provide.

The key innovation is the spectral filtering stage. Instead of applying RSI directly to raw price, the indicator first passes price data through a Discrete Fourier Transform (DFT) to extract dominant frequency components, then applies RSI-weighted filtering to produce a cleaner, less noisy momentum signal. This filtered signal is then blended with the Stochastic Momentum Index to create a composite that captures both trend momentum and mean-reversion potential.

istantanea

Why This Indicator Exists

Standard momentum oscillators have well-known limitations. RSI is noisy on lower timeframes and produces frequent false signals in choppy markets. Stochastic oscillators are fast but whipsaw-prone. Neither incorporates volume information. This indicator addresses these issues by layering three complementary approaches:

  • Spectral-Filtered RSI: Applies a Discrete Fourier Transform to extract the dominant price cycle, then weights the filtered output by RSI distance from the midpoint. This removes high-frequency noise while preserving the meaningful momentum signal. The result is a smoother RSI that responds to genuine trend changes rather than random fluctuations.
  • Stochastic Momentum Index: Measures where the close is relative to the midpoint of the recent high-low range, double-smoothed with configurable EMA periods. Unlike classic stochastic which measures close relative to the range boundaries, SMI measures distance from the center — making it more sensitive to directional momentum and less prone to ceiling/floor effects.
  • CVD Divergence: Tracks Cumulative Volume Delta (buy volume minus sell volume) and compares it to price extremes. When price makes a new low but CVD is higher than its previous low, buying pressure is diverging from price — a bullish signal. The reverse applies for bearish divergences. This adds a volume-based confirmation layer that pure price-based oscillators lack.


How the Spectral Filter Works

The spectral filtering process uses a Discrete Fourier Transform — the same mathematical tool used in signal processing, audio analysis, and scientific computing — to decompose price data into frequency components:

Pine Script®


The process works in four stages:

  • Stage 1 — Short RSI Weighting: A short-period RSI is calculated and converted to an "absolute distance from 50" value. Bars where RSI is far from 50 (strong momentum) receive higher weight in the filter.
  • Stage 2 — Forward DFT: Price data is transformed into the frequency domain using a configurable number of harmonics (default 3). The magnitude spectrum is extracted, and the DC component (the dominant low-frequency trend) becomes the filtered subject.
  • Stage 3 — RSI-Weighted Smoothing: The filtered subject is smoothed using the RSI absolute distance as weights. This means the filter responds more to bars with strong momentum and less to bars with weak, indecisive momentum.
  • Stage 4 — Final RSI: RSI is calculated on the filtered data with the main length (default 21). A divergence component (rate of change of the spectral RSI) is added to create the final Cadence RSI value.


The result is an RSI-like oscillator that is significantly smoother than standard RSI while still being responsive to genuine trend changes. The Fourier harmonics parameter controls how many frequency components are retained — fewer harmonics produce a smoother signal, more harmonics preserve more detail.

Stochastic Momentum Index Component

The SMI component provides a complementary momentum perspective. While the spectral RSI focuses on trend momentum, the SMI captures where price sits within its recent range:

  • The lookback period defines the range (highest high, lowest low)
  • The distance from the midpoint of that range is double-smoothed with two EMA passes
  • The range itself is also double-smoothed and halved to create the denominator
  • The resulting value oscillates between -100 and +100, where positive values indicate price is above the range midpoint and negative values indicate it is below
  • This is normalized to 0-100 for blending with the spectral RSI


The SMI is particularly useful for detecting mean-reversion opportunities. When the spectral RSI shows a trend but the SMI is at an extreme, it suggests the trend may be overextended.

Composite Blending

The final composite oscillator blends the spectral RSI (60% weight) with the normalized SMI (40% weight). This weighting prioritizes the trend-following spectral RSI while incorporating the mean-reversion sensitivity of the SMI. The composite oscillates between 0 and 100, with 50 as the neutral midpoint.

The histogram displays the difference from 50, making it easy to see momentum direction and intensity at a glance. Positive histogram bars indicate bullish momentum, negative bars indicate bearish momentum, and the gradient coloring intensifies with momentum strength.

Signal Line and Crossovers

An EMA-based signal line (default 9 periods) is applied to the composite. Crossovers between the composite and signal line provide timing signals:

  • Bull Cross: Composite crosses above the signal line — momentum is accelerating upward
  • Bear Cross: Composite crosses below the signal line — momentum is decelerating or reversing
  • The distance between composite and signal line indicates momentum conviction — wide separation means strong momentum, tight convergence suggests a potential cross is forming


Z-Score Extreme Detection

The indicator calculates a Z-score of the composite value over a configurable lookback (default 50 bars). When the Z-score exceeds +2.0 or falls below -2.0, the momentum is at a statistical extreme — more than two standard deviations from the mean. These events are marked with square markers and indicate:

  • Potential exhaustion of the current move
  • High probability of mean reversion
  • Possible climax buying or selling


Z-score extremes are not automatic reversal signals — strong trends can sustain extremes for extended periods. They are best used as warnings to tighten stops or take partial profits.

Wyckoff Absorption Detection

The indicator detects Wyckoff absorption events — bars where volume is significantly above average (1.5x) but the price range is significantly below average (0.5x). This pattern indicates that large institutional orders are being filled without moving price, which often precedes a directional breakout. Absorption markers appear as circles at the midline.

Visual Design

The indicator uses a "Solar Flare" color theme — golds, ambers, magentas, and plasma purples on a dark background:

  • Composite Line: Neon glow effect with three layered plots (outer glow at 85% transparency, mid glow at 65%, core line at full intensity). Color adapts to trend state — gold/amber for bullish, magenta/red for bearish, ash for neutral.
  • Gradient Histogram: 10-level color gradient from bright gold (strong bull) through amber to magenta (strong bear). Rising momentum within a direction intensifies the color.
  • Signal Line: Plasma purple with glow effect
  • Zone Fills: Subtle fills between threshold lines — gold tint in the bull zone, magenta tint in the bear zone, ash in the neutral zone
  • OB/OS Fills: When the composite enters overbought (>75) or oversold (<25) territory, a colored fill highlights the extreme
  • SMI Reference: A thin blue line showing the normalized SMI for comparison
  • Markers: Triangles for signal crossovers, diamonds for CVD divergences, squares for Z-score extremes, circles for absorption


istantanea

HUD Dashboard

The real-time HUD displays 14 metrics:

  • Composite value with color-coded bull/bear/neutral state
  • Trend direction (Bullish/Bearish/Neutral)
  • Z-Score value with classification (Extreme Bull/Bear, Strong, Normal)
  • Momentum Percentile Rank (0-100%)
  • SMI value
  • Signal Line distance (Wide/Moderate/Tight)
  • Volume Flow direction (Buying/Selling/Neutral) from CVD
  • Spectral RSI component value
  • Momentum Strength percentage with classification (Very Strong to Very Weak)
  • Overbought/Oversold pressure state
  • Divergence status (Bull Div/Bear Div/None)
  • Current mode description (Bull Momentum/Bear Momentum/Consolidating)


Input Parameters

Spectral RSI:
  • RSI Length: Main RSI period (default: 21)
  • Source: Price source (default: close)
  • Filter Length: Short RSI period for weighting (default: 12)
  • Fourier Harmonics: Number of DFT components (default: 3). Lower = smoother, higher = more detail.


Stochastic Momentum:
  • SMI Lookback: Range period (default: 13)
  • SMI Smooth 1/2: Double-smoothing EMA periods (default: 25/2)
  • Signal Length: Signal line EMA period (default: 13)


Volume Delta:
  • Show CVD Divergence: Toggle divergence detection
  • CVD Divergence Lookback: Period for comparing CVD extremes to price extremes (default: 14)


Levels:
  • Overbought/Oversold: Extreme thresholds (default: 75/25)
  • Bull/Bear Threshold: Trend classification levels (default: 58/42)


How to Use This Indicator

Step 1: Read the Composite Direction
Above 58 = bullish momentum. Below 42 = bearish momentum. Between = consolidation. The histogram makes this immediately visible.

Step 2: Watch for Signal Crossovers
Bull crosses (composite above signal) in the lower half of the range are potential long entries. Bear crosses in the upper half are potential short entries. Crosses near the midline are less significant.

Step 3: Check for Divergences
CVD divergences at price extremes are powerful reversal warnings. A bullish CVD divergence at an oversold composite reading is a high-probability long setup.

Step 4: Monitor Z-Score Extremes
Z-score beyond +/-2.0 warns of potential exhaustion. Consider tightening stops or taking partial profits when the Z-score reaches extreme levels.

Step 5: Use Absorption as Early Warning
Absorption events (high volume, small range) often precede breakouts. When absorption appears near a threshold level, be prepared for a directional move.

Best Practices

  • The spectral filter works best on timeframes with sufficient data — 5-minute and above is recommended
  • Fewer Fourier harmonics (2-3) produce a smoother, more trend-following signal. More harmonics (5-8) produce a more responsive but noisier signal.
  • The composite is most reliable when the spectral RSI and SMI agree. Divergence between the two components suggests mixed conditions.
  • CVD divergences are most significant at overbought/oversold extremes
  • Z-score extremes in trending markets can persist — do not blindly fade them
  • The signal line crossover is a timing tool, not a standalone entry signal. Combine with price action and structure analysis.
  • Absorption events are context-dependent — they are most meaningful near support/resistance levels


Limitations

  • The DFT calculation is computationally intensive. Very high harmonic counts may slow chart loading on lower timeframes with large datasets.
  • The spectral filter introduces a small amount of lag compared to raw RSI. This is the tradeoff for noise reduction.
  • CVD divergence detection uses a simple comparison of extremes over the lookback period. It may miss complex divergences or flag simple pullbacks as divergences.
  • Buy/sell volume separation is estimated from candle direction, not true order flow data.
  • The composite blending weights (60/40) are fixed. Different instruments or timeframes might benefit from different weights.
  • Z-score extremes are relative to the lookback period. A Z-score of +2.0 over 50 bars may not be extreme over 200 bars.
  • Like all oscillators, this indicator can remain at extremes during strong trends. It is not a contrarian tool by default.


Technical Implementation

Built with Pine Script v6 using:
  • Custom Discrete Fourier Transform implementation (forward and inverse) with configurable harmonics
  • RSI-weighted spectral filtering for noise reduction
  • Double-smoothed Stochastic Momentum Index with normalization
  • Cumulative Volume Delta tracking with divergence detection
  • Z-score calculation for statistical extreme identification
  • Wyckoff absorption detection (effort vs result)
  • 10-level gradient histogram coloring function
  • Multi-layer neon glow effect on composite and signal lines
  • barstate.isconfirmed gating on all signal markers
  • 10 alert conditions covering threshold crosses, divergences, signal crossovers, and Z-score extremes


Originality Statement

This indicator is original in its synthesis of spectral analysis with momentum oscillators and volume delta. While RSI, stochastic, and CVD are established concepts, this indicator is justified because:

  • The Discrete Fourier Transform spectral filtering applied to RSI calculation is a novel approach that significantly reduces noise while preserving signal responsiveness
  • The RSI-weighted filtering stage ensures the spectral filter responds more to high-momentum bars and less to noise, creating an adaptive smoothing mechanism
  • Blending spectral RSI with SMI combines trend-following and mean-reversion perspectives into a single composite that captures both dimensions of momentum
  • CVD divergence detection adds a volume-based confirmation layer that pure price-based oscillators cannot provide
  • Z-score extreme detection provides statistical context for momentum readings, helping traders distinguish between normal momentum and genuine extremes
  • Wyckoff absorption integration connects volume analysis with momentum analysis in a way that standard oscillators do not
  • The Solar Flare theme with gradient histogram and neon glow provides immediate visual clarity about momentum direction and intensity


Disclaimer

This indicator is provided for educational and informational purposes only. It is not financial advice or a recommendation to buy or sell any financial instrument. Momentum oscillators measure the rate and direction of price change — they do not predict future price movement. Overbought conditions can persist in strong uptrends, and oversold conditions can persist in strong downtrends. Signal crossovers and divergences are probabilistic, not deterministic. Past momentum patterns do not guarantee future behavior. Always use proper risk management and never risk more than you can afford to lose. The author is not responsible for any losses incurred from using this indicator.

-Made by officialjackofalltrades

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.