OPEN-SOURCE SCRIPT

Harmonic Resonance Detector [JOAT]

4 475
Harmonic Resonance Detector [JOAT]

Introduction

The Harmonic Resonance Detector is an advanced open-source Fibonacci analysis indicator that combines multi-wave Fibonacci retracements, confluence zone detection, golden ratio harmonics, and density heatmapping into a unified harmonic analysis system. This indicator helps traders identify high-probability reversal and continuation zones by analyzing where multiple Fibonacci levels from different swing waves converge, creating magnetic price attraction zones.

Unlike basic Fibonacci tools that draw levels from a single swing, this system analyzes three simultaneous swing waves (primary, secondary, tertiary) and identifies where their Fibonacci levels cluster. These confluence zones represent areas where multiple timeframes and swing structures agree on key levels, significantly increasing the probability of price reaction. The indicator is designed for traders who understand that Fibonacci levels work best when multiple waves confirm the same price zone.

Why This Indicator Exists

This indicator addresses a fundamental limitation of traditional Fibonacci analysis: single-swing Fibonacci levels are subjective and often unreliable. Different traders draw different swings and get different levels. By combining multiple swing analyses and identifying confluence, this indicator reveals:

  • Triple Swing Analysis: Analyzes three different swing lengths simultaneously (20, 50, 100 periods) to capture short, medium, and long-term structure
  • Confluence Zone Detection: Identifies where multiple Fibonacci levels cluster within tolerance - these zones act as price magnets
  • Golden Pocket Highlighting: Marks the 0.618-0.65 retracement zone - the highest probability reversal area based on golden ratio
  • Fibonacci Extensions: Projects 1.272, 1.414, and 1.618 extension levels for profit targets beyond the swing range
  • Density Heatmap: Visual representation of Fibonacci level concentration - darker colors = more confluence
  • Liquidity Sweep Detection: Identifies when price breaks highs/lows but closes back inside - signals institutional traps


Each component provides a different lens on harmonic structure. Triple swing analysis shows multi-timeframe agreement, confluence zones show magnetic levels, golden pocket shows optimal entry, extensions show targets, heatmap shows density, and sweeps show manipulation. Together, they create a comprehensive view of harmonic resonance.

תמונת-בזק

Core Components Explained

1. Triple Swing Fibonacci Analysis

The indicator calculates Fibonacci retracements from three different swing lengths simultaneously:

Pine Script®
// Calculate swing high/low for each period swingHigh1 = ta.highest(high, 20) // Primary wave swingLow1 = ta.lowest(low, 20) swingHigh2 = ta.highest(high, 50) // Secondary wave swingLow2 = ta.lowest(low, 50) swingHigh3 = ta.highest(high, 100) // Tertiary wave swingLow3 = ta.lowest(low, 100) // Calculate Fibonacci levels for each swing fib1 = calculateFibs(swingHigh1, swingLow1) fib2 = calculateFibs(swingHigh2, swingLow2) fib3 = calculateFibs(swingHigh3, swingLow3)


For each swing, the indicator calculates standard Fibonacci retracement levels:
  • 23.6% - Shallow retracement, weak pullback
  • 38.2% - Moderate retracement, common in strong trends
  • 50.0% - Equilibrium level, psychological significance
  • 61.8% - Golden ratio, highest probability reversal zone
  • 78.6% - Deep retracement, last chance before trend failure


By analyzing three different swing lengths, the indicator captures short-term, medium-term, and long-term structure simultaneously. When levels from all three swings align, it creates powerful confluence.

2. Confluence Zone Detection

The indicator identifies zones where multiple Fibonacci levels cluster within a tolerance percentage:

Pine Script®
confluenceTolerance = 0.3 // Default 0.3% // For each Fibonacci level, count how many other levels are nearby for each level in allFibLevels: confluenceCount = 0 for each otherLevel in allFibLevels: if abs(level - otherLevel) / level * 100 <= confluenceTolerance: confluenceCount += 1 if confluenceCount >= 3: // Minimum 3 levels clustering createConfluenceZone(level, confluenceCount)


Confluence zones are displayed as:
  • Horizontal boxes spanning the tolerance range
  • Color intensity based on confluence count (4+ levels = red, 3 levels = orange, 2 levels = yellow)
  • Labels showing "3x CONFLUENCE", "4x CONFLUENCE", etc.
  • Thicker borders for higher confluence zones


The more Fibonacci levels that converge at a price zone, the stronger the magnetic effect. 4x or 5x confluence zones are extremely high-probability reaction areas.

3. Golden Pocket Visualization

The Golden Pocket is the zone between 0.618 and 0.65 Fibonacci retracement - the highest probability reversal area:

Pine Script®
fib618 = swingLow + (swingHigh - swingLow) * 0.618 fib650 = swingLow + (swingHigh - swingLow) * 0.650 goldenTop = max(fib618, fib650) goldenBottom = min(fib618, fib650)


The Golden Pocket is special because:
  • Based on the golden ratio (phi = 1.618), found throughout nature and markets
  • Represents optimal balance between retracement depth and trend continuation
  • Historically shows highest win rate for reversal trades
  • Often coincides with institutional order placement zones


The indicator highlights the Golden Pocket with:
  • Multi-layer gradient gold box
  • "GOLDEN POCKET" label at center
  • Enhanced candlestick coloring when price is inside (gold for bullish, brown for bearish)
  • Background gradient when price enters the zone


4. Fibonacci Extensions

Extensions project levels beyond the swing range for profit targets:

Pine Script®
// Extension levels ext1272 = swingLow + (swingHigh - swingLow) * 1.272 ext1414 = swingLow + (swingHigh - swingLow) * 1.414 ext1618 = swingLow + (swingHigh - swingLow) * 1.618


Extension levels represent:
  • 127.2% - First extension target, common profit-taking zone
  • 141.4% - Square root of 2, geometric harmony level
  • 161.8% - Golden ratio extension, major target zone


Extensions are drawn as dashed lines with purple gradient colors. They show where price is likely to find resistance after breaking through the swing high (or support after breaking swing low).

5. Confluence Density Heatmap

The heatmap visualizes Fibonacci level concentration across the price range:

The indicator:
  • Divides the recent price range into 20 grid cells
  • Counts how many Fibonacci levels fall into each cell
  • Colors cells based on density (blue = low, red = high)
  • Displays as vertical bars on the left side of the chart


The heatmap reveals:
  • Zones with highest Fibonacci concentration (darkest red)
  • Gaps where few Fibonacci levels exist (blue or empty)
  • Vertical distribution of harmonic structure
  • Quick visual reference for key zones


Traders can quickly identify the most important price levels by looking for the darkest red cells in the heatmap.

6. Liquidity Sweep Detection

Liquidity sweeps occur when price breaks a swing high/low but closes back inside the range - a classic institutional trap:

Pine Script®
// Detect sweep: high breaks previous swing high but close is below it liquiditySweepHigh = high > prevSwingHigh and close < prevSwingHigh // Detect sweep: low breaks previous swing low but close is above it liquiditySweepLow = low < prevSwingLow and close > prevSwingLow


When sweeps occur:
  • Dashed horizontal line marks the swept level
  • "LIQ SWEEP" label appears
  • Often precedes reversal as institutions trapped retail traders
  • Combines with Fibonacci confluence for high-probability setups


Liquidity sweeps at Fibonacci confluence zones are especially powerful - they signal institutional positioning complete and reversal imminent.

7. Equilibrium Boxes (EQH/EQL)

Equilibrium boxes mark 50% retracement zones throughout the chart:

The indicator:
  • Identifies significant ranges throughout lookback period
  • Calculates 50% level (equilibrium) for each range
  • Draws grey boxes around equilibrium with dashed center line
  • Labels with "EQH" (Equal Highs) marker


Equilibrium zones represent fair value and often act as support/resistance. Price tends to gravitate toward equilibrium before continuing or reversing.

תמונת-בזק

Visual Elements

  • Fibonacci Lines: Dotted lines at 23.6%, 38.2%, 50%, 61.8%, 78.6% with color coding
  • Extension Lines: Dashed purple lines at 127.2%, 141.4%, 161.8%
  • Confluence Zones: Horizontal boxes with intensity-based coloring and count labels
  • Golden Pocket: Multi-layer gradient gold box with center label
  • Density Heatmap: Vertical gradient bars showing Fibonacci concentration
  • Liquidity Sweeps: Dashed lines with "LIQ SWEEP" labels
  • Equilibrium Boxes: Grey boxes with dashed center lines and "EQH" labels
  • Enhanced Candles: Gold/orange coloring in Golden Pocket, red/green at confluence zones
  • Background Gradients: Premium zone (red), Discount zone (green), Golden Pocket (gold)
  • Dashboard: Real-time confluence metrics and trade signals


The dashboard displays 8 key metrics:
1. Active Zones (count of confluence zones)
2. Peak Confluence (highest confluence count)
3. Nearest Zone (distance to closest confluence)
4. Magnetic Pull (Extreme/Strong/Moderate/Weak)
5. Golden Zone (Active/Inactive)
6. Heatmap Density (total Fibonacci levels)
7. Trade Signal (Sniper Entry/Valid Setup/Wait)

Input Parameters

Harmonic Waves:
  • Primary Wave: First swing length (default: 20)
  • Secondary Wave: Second swing length (default: 50)
  • Tertiary Wave: Third swing length (default: 100)
  • Golden Pocket: Enable 0.618-0.65 zone highlighting


Confluence Engine:
  • Resonance Tolerance: Percentage range for confluence (default: 0.3%)
  • Min Harmonic Count: Minimum levels required for confluence (default: 3)
  • Magnetic Zones: Enable/disable confluence zone boxes


Visualization:
  • Fibonacci Levels: Show/hide retracement lines
  • Confluence Zones: Show/hide confluence boxes
  • Density Heatmap: Show/hide vertical heatmap
  • Extensions: Show/hide 1.272, 1.414, 1.618 levels
  • Equilibrium Boxes: Show/hide EQH zones
  • Liquidity Sweeps: Show/hide sweep markers
  • Gradient Backgrounds: Show/hide value zone colors
  • Enhanced Candlesticks: Enable special candle coloring


How to Use This Indicator

Step 1: Identify Confluence Zones
Look for horizontal boxes with "3x CONFLUENCE" or higher labels. These are magnetic zones where price is likely to react. 4x+ confluence = highest probability.

Step 2: Check Golden Pocket Status
Dashboard shows if Golden Pocket is active. When price enters the golden zone (0.618-0.65), it's optimal reversal area. Candles turn gold.

Step 3: Monitor Nearest Zone Distance
Dashboard shows distance to nearest confluence. <0.5% = price is at the zone. <1.0% = approaching. >2.0% = far away.

Step 4: Assess Magnetic Pull Strength
Dashboard shows pull strength. "EXTREME" = 4+ confluence within 0.5%. "STRONG" = 3+ confluence within 1.0%. Trade extreme and strong only.

Step 5: Watch for Liquidity Sweeps
When price sweeps a high/low at a confluence zone and reverses, it's a sniper entry. Institutions trapped retail and are now reversing.

Step 6: Use Extensions for Targets
After entry at confluence zone, use extension levels (127.2%, 141.4%, 161.8%) as profit targets. These are natural resistance/support zones.

Step 7: Check Trade Signal
Dashboard shows "SNIPER ENTRY" when price is within 0.5% of 4+ confluence. "VALID SETUP" for 3+ confluence within 1.0%. "WAIT" otherwise.

Best Practices

  • Higher confluence = higher probability - prioritize 4x+ zones
  • Golden Pocket + confluence = best reversal setups
  • Liquidity sweeps at confluence zones = institutional positioning
  • Use heatmap for quick visual reference of key zones
  • Extensions work best after confluence zone holds
  • Equilibrium boxes show fair value - expect gravitational pull
  • Premium/discount background shows context - buy discount, sell premium
  • Enhanced candles signal when price is at key zones
  • Multiple timeframe confluence (all three swings) = strongest setups
  • Confluence zones can act as support after breaking resistance (and vice versa)


Indicator Limitations

  • Fibonacci analysis is subjective - different swing selections produce different levels
  • Confluence zones show where levels cluster, not guaranteed reversals
  • Golden Pocket doesn't always hold - strong trends can blow through it
  • Liquidity sweeps can extend further than expected (double sweeps)
  • Heatmap density doesn't account for level importance (all levels weighted equally)
  • Extensions may not be reached in weak trends
  • Tolerance setting affects confluence detection - too tight misses zones, too wide creates false zones
  • The indicator shows harmonic structure, not fundamental drivers
  • Confluence zones can fail during news events or market shocks


Technical Implementation

Built with Pine Script v6 using:
  • Triple swing Fibonacci calculations with automatic trend detection
  • Confluence detection algorithm with tolerance-based clustering
  • Golden Pocket identification and highlighting system
  • Fibonacci extension projections (1.272, 1.414, 1.618)
  • Density heatmap with grid-based level counting
  • Liquidity sweep detection with close confirmation
  • Equilibrium box generation throughout chart history
  • Enhanced candlestick coloring based on zone proximity
  • Multi-gradient background system for value zones
  • Real-time dashboard with 8 harmonic metrics


The code is fully open-source and can be modified to suit individual trading styles and preferences.

Originality Statement

This indicator is original in its comprehensive harmonic integration approach. While individual components (Fibonacci retracements, golden ratio, extensions) are established concepts, this indicator is justified because:

  • It synthesizes three simultaneous swing analyses into unified confluence detection
  • The confluence algorithm identifies clustering zones with configurable tolerance
  • Golden Pocket highlighting with enhanced visualization and candlestick coloring
  • Density heatmap provides visual representation of Fibonacci concentration
  • Liquidity sweep detection combines with Fibonacci zones for trap identification
  • Equilibrium box system marks fair value zones throughout chart history
  • Multi-gradient background system shows premium/discount context
  • Magnetic pull strength quantification based on confluence and proximity
  • Real-time dashboard presents 8 metrics simultaneously for holistic harmonic analysis


Each component contributes unique information: Triple swings show multi-timeframe structure, confluence shows magnetic zones, golden pocket shows optimal entry, extensions show targets, heatmap shows density, sweeps show manipulation, and equilibrium shows fair value. The indicator's value lies in presenting these complementary perspectives simultaneously with unified classification and actionable trade signals.

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 and is not suitable for all investors.

Fibonacci analysis is a tool for identifying potential support and resistance zones, not a crystal ball for predicting future price movement. Confluence zones do not guarantee reversals. Golden Pocket does not guarantee entries. Extensions may not be reached. Past harmonic patterns do not guarantee future harmonic patterns. Market conditions change, and strategies that worked historically may not work in the future.

The zones displayed are analytical constructs based on current market data, not predictions of future price movement. High confluence scores do not guarantee profitable trades. Users must conduct their own analysis and risk assessment before making trading decisions.

Always use proper risk management, including stop losses and position sizing appropriate for your account size and risk tolerance. Never risk more than you can afford to lose. Consider consulting with a qualified financial advisor before making investment decisions.

The author is not responsible for any losses incurred from using this indicator. Users assume full responsibility for all trading decisions made using this tool.

-Made with passion by officialjackofalltrades

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.