Trend Resonance Oscillator [JOAT]Trend Resonance Oscillator
Introduction
The Trend Resonance Oscillator is an open-source non-overlay indicator that measures multi-timeframe trend alignment and produces a composite resonance score. It fetches trend data from up to five configurable timeframes, calculates whether they agree on direction, and outputs an oscillator that reflects the degree of alignment. When most or all timeframes point the same way, the oscillator reaches extreme values and the indicator declares a state of "resonance" — a condition where directional conviction is high across the time spectrum. It also includes quantum-inspired coherence scoring, harmonic pattern detection, and momentum alignment visualization.
Built with Pine Script v6, the indicator uses custom types for trend state, resonance state, timeframe data, quantum state, and harmonic patterns.
Why This Indicator Exists
A trade taken in the direction of the 5-minute trend may fail if the 1-hour and daily trends disagree. Multi-timeframe alignment is one of the most reliable filters for trade quality, but checking multiple timeframes manually is tedious and subjective. This indicator automates that process by:
Simultaneous MTF analysis: Fetches close, EMA, and rate-of-change data from five configurable timeframes in a single indicator
Alignment scoring: Quantifies how many timeframes agree on direction and how strong each trend is, producing a single composite score
Resonance detection: Identifies periods when alignment exceeds a configurable threshold, signaling high-conviction directional conditions
Confluence signals: Generates labeled signals when a minimum number of timeframes align, providing clear entry confirmation
Coherence and entanglement metrics: Measures the consistency and correlation between timeframe trends, adding depth beyond simple directional agreement
Core Components Explained
1. Multi-Timeframe Trend Detection
For each of the five timeframes (default: 5m, 15m, 1H, 4H, Daily), the indicator fetches close price, EMA, and rate-of-change using `request.security()` with proper lookahead settings to avoid repainting:
float _tf1Close = request.security(syminfo.tickerid, tf1, close, barmerge.gaps_off, barmerge.lookahead_off)
float _tf1EMA = request.security(syminfo.tickerid, tf1, _globalEMA, barmerge.gaps_off, barmerge.lookahead_off)
Each timeframe's trend is classified as bullish, bearish, or flat based on the percentage difference between close and EMA relative to a configurable threshold (default 0.5%). The trend strength is calculated as the magnitude of that percentage difference, capped at 100.
2. Alignment Score Calculation
The alignment score counts how many timeframes are bullish versus bearish, then produces a normalized score from -100 (all bearish) to +100 (all bullish):
+100: All active timeframes are bullish — maximum bullish alignment
+60: Majority bullish with some neutral — strong bullish bias
0: Equal bullish and bearish — no directional consensus
-60: Majority bearish — strong bearish bias
-100: All bearish — maximum bearish alignment
The alignment score is weighted by the average trend strength across all active timeframes, so a +80 alignment with strong individual trends produces a higher oscillator value than +80 alignment with weak trends.
3. Resonance Detection
Resonance occurs when the ratio of aligned timeframes to total active timeframes exceeds the resonance threshold (default 0.7) and the aligned count meets the minimum confluence requirement (default 4 timeframes). During resonance, the background is tinted to indicate the directional bias, and a duration counter tracks how long the resonance state has persisted.
Sustained resonance (high duration) suggests a strong, established trend. New resonance (low duration) may signal the beginning of a directional move. The dashboard displays the resonance score, aligned count, and duration for quick assessment.
The Trend Resonance Oscillator panel showing the main oscillator line with gradient coloring, MTF trend bars at the bottom showing individual timeframe directions, resonance background shading during a strong bullish alignment, and confluence/resonance signal labels
4. Quantum Coherence and Entanglement
The indicator calculates two additional metrics inspired by quantum physics concepts (used as analytical metaphors, not literal physics):
Coherence: The ratio of aligned timeframes to total timeframes. A coherence of 1.0 means perfect agreement. When coherence exceeds the threshold (default 0.8), the indicator enters a "coherent" state, which is visualized as a subtle wave pattern on the oscillator.
Entanglement: Measures the pairwise correlation between all timeframe trends. For each pair of timeframes, if they agree on direction, the entanglement score increases; if they disagree, it decreases. High entanglement means timeframes are moving in lockstep.
for i = 0 to 3
for j = i + 1 to 4
if trend_i != 0 and trend_j != 0
correlation = trend_i == trend_j ? 1.0 : -1.0
entanglement += correlation
pairs += 1
When the quantum superposition score (combination of coherence and entanglement) exceeds a threshold, a "quantum collapse" signal fires, indicating that all timeframes have converged to a single directional state.
5. Harmonic Pattern Detection
The harmonic module detects cyclical patterns in the resonance data. When resonance is sustained for more than 10 bars, the pattern is classified as a sine wave (smooth, established trend). When resonance is new or intermittent, it is classified as a square wave (choppy, emerging trend). The harmonic wave is plotted as a subtle overlay on the oscillator.
6. Confluence and Signal System
The indicator generates three tiers of signals, with higher tiers taking priority:
CONF (Confluence): Minimum timeframes aligned with alignment score >= 70
RES (Resonance): Strong resonance with score >= 80
QTM (Quantum): Quantum collapse — all metrics converge to a single state
Each signal fires only on its first bar (not continuously), preventing chart clutter. Signals are color-coded with gradient intensity based on the underlying strength.
Visual Elements
Main Oscillator: Smoothed alignment score plotted as a line with gradient coloring from bearish to bullish
Reference Levels: Lines at 0 (neutral), +/-50 (moderate), +/-80 (strong)
MTF Trend Bars: Five colored column bars at the bottom of the panel, each representing one timeframe's trend direction and strength
Resonance Background: Tinted background during resonance states
Quantum Superposition Line: Step-line showing the quantum composite score
Coherence Wave: Subtle area plot showing coherence oscillation
Harmonic Pattern: Sine/square wave overlay during active resonance
Momentum Alignment: Area histogram showing aggregate momentum across timeframes
Convergence/Divergence: Histogram showing agreement between momentum and oscillator
Signal Labels: CONF, RES, and QTM labels at signal points
Entanglement Lines: Visual connections when timeframe entanglement is high
Dashboard: Comprehensive table showing each timeframe's trend, strength, and the aggregate resonance metrics
Input Parameters
Multi-Timeframe Settings:
Toggle and configure each of 5 timeframes (default: 5m, 15m, 1H, 4H, Daily)
Trend Detection:
Trend EMA Length (default 20), Momentum Length (default 14), Trend Threshold (default 0.5%)
Resonance Settings:
Resonance Lookback (default 20), Resonance Threshold (default 0.7)
Show Resonance Zones toggle
Alignment Scoring:
Min TFs for Confluence (default 4)
Show Alignment Score and Confluence Signals
Advanced Resonance:
Quantum Resonance, Coherence Waves, Entanglement Lines, Harmonic Patterns toggles
Coherence Threshold (default 0.8), Harmonic Period (default 8)
Visual Settings:
Show Oscillator, MTF Bars, Dashboard, Glow Effects, Waveform
Color Scheme: Quantum, Classic, Professional, Neon
How to Use This Indicator
Step 1: Check the MTF trend bars at the bottom of the panel. If all five bars are the same color (all bullish or all bearish), you have strong multi-timeframe alignment.
Step 2: Read the oscillator value. Values above +50 indicate moderate bullish alignment; above +80 indicates strong alignment. The inverse applies for bearish readings.
Step 3: Watch for resonance background shading. When the background turns bullish or bearish, the indicator has detected sustained multi-timeframe agreement — this is the highest-conviction environment for directional trades.
Step 4: Use CONF, RES, and QTM signals as entry confirmations. A CONF signal in the direction of the oscillator provides moderate confirmation. A RES or QTM signal provides strong confirmation.
Step 5: Monitor the momentum alignment area. When momentum and the oscillator agree, the move has both directional alignment and momentum behind it. When they diverge, the move may be losing steam.
Dashboard showing all five timeframes with their individual trend states, the aggregate resonance score, coherence level, entanglement reading, and harmonic pattern status
Indicator Limitations
Multi-timeframe data requires sufficient history on all selected timeframes. On newly listed instruments, higher timeframe data may be limited.
The indicator uses `request.security()` with `barmerge.lookahead_off` to prevent repainting, but the inherent delay of higher timeframe data means signals reflect confirmed (not real-time) higher timeframe states.
Alignment does not guarantee profitable trades. All timeframes can align in one direction and then reverse simultaneously.
The quantum and harmonic features are analytical metaphors that provide useful metrics, not literal physics simulations.
On very low timeframes (1m or less), higher timeframe data updates infrequently, which can make the oscillator appear static for extended periods.
The indicator makes multiple `request.security()` calls, which counts against TradingView's security call limit.
Originality Statement
This indicator is original in its comprehensive multi-timeframe resonance framework. While MTF trend indicators exist, this indicator is justified because:
It produces a quantified resonance score that measures not just direction but the degree and duration of multi-timeframe agreement
The coherence and entanglement metrics add pairwise correlation analysis between timeframes, going beyond simple directional counting
The three-tier signal system (CONF/RES/QTM) provides graduated confidence levels based on the strength of alignment
Harmonic pattern detection on the resonance data identifies whether alignment is sustained (sine) or emerging (square)
The momentum alignment overlay shows whether aggregate momentum across timeframes supports the directional reading
The weighted oscillator combines alignment direction with individual trend strength for a more nuanced composite score
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. Trading involves substantial risk of loss. Multi-timeframe alignment is a powerful filter but does not guarantee profitable trades. Always use proper risk management. The author is not responsible for any losses incurred from using this indicator.
-Made with passion by officialjackofalltrades
Pine Script® インジケーター




