OPEN-SOURCE SCRIPT

Fibonacci Volume Confluence Engine [PhenLabs]

4 760
📊 Fibonacci Volume Confluence Engine [PhenLabs]
Version: PineScript™ v6

Snapshot

📌 Description

The Fibonacci Volume Confluence Engine is a multi-layered confluence detection system that combines ATR-filtered swing pivot detection with a bar-by-bar volume profile to automatically identify and score every Fibonacci retracement level by the volume traded within it. Rather than drawing static lines and leaving interpretation to the trader, this engine classifies each level as Strong, Moderate, or Weak based on real market participation — separating the levels the market genuinely respects from those it simply passes through.

At its core, the indicator anchors Fibonacci retracements to structurally confirmed swing highs and lows, filtered by ATR distance to eliminate noise. A rolling volume histogram is then constructed over a configurable lookback window and mapped against each of the seven Fibonacci levels. The result is a set of visually distinct confluence zones on your chart, backed by quantified volume data rather than discretionary judgment.

Beyond Fibonacci, the engine incorporates Break of Structure and Change of Character detection from the confirmed swing sequence, an optional Multi-Timeframe Fibonacci overlay sourced from any higher timeframe, and a live on-chart dashboard summarising trend direction, key levels, confluence counts, and the most recent structure signal — making it a complete structural analysis tool rather than a single-purpose retracement drawer.

🚀 Points of Innovation

  • Volume-scored Fibonacci levels — every level is quantitatively graded by the concentration of volume traded within its price zone, not by subjective confluence counting
  • ATR-adaptive pivot filtering — swing highs and lows are only accepted when their distance from the opposing swing meets a minimum ATR multiple, keeping anchors structurally meaningful across all instruments and timeframes
  • Manual bar-loop volume profile — the histogram is built with a direct bar iteration loop rather than built-in functions with series-length limitations, guaranteeing stable computation from the very first confirmed pivot
  • Integrated BOS and CHoCH detection — structure breaks are classified as either continuation or reversal signals based on the confirmed swing sequence, with five individual alert conditions
  • Multi-timeframe Fibonacci overlay — a second independent Fibonacci set sourced from any higher timeframe can be displayed simultaneously on the current chart with its own style controls


🔧 Core Components

  • ATR-Filtered Swing Engine: Detects pivot highs and lows using configurable lookback length, then filters each candidate by requiring a minimum ATR-scaled distance from the opposing swing. Only structurally significant pivots are accepted as Fibonacci anchors.
  • Fibonacci Retracement Layer: Draws the seven standard levels (0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%) from the most recent confirmed swing pair. Direction is automatically set to bullish or bearish based on which swing type was most recently confirmed.
  • Volume Profile Engine: Iterates over up to 500 bars, assigns each bar’s volume to a price bin based on its midpoint, and builds a 10–50 bin histogram over the configurable lookback window. Uses array pre-allocation with set-based zero-filling for runtime stability.
  • Confluence Classifier: Maps each Fibonacci level to its corresponding volume bin, sums the center bin plus weighted adjacent bins for a smoothed reading, then classifies the result as Strong (top 30%), Moderate (40–70%), or Weak (20–40%) relative to the peak bin.
  • BOS and CHoCH Detector: Compares the last two confirmed swing highs and lows to determine trend direction (HH+HL = uptrend, LH+LL = downtrend), then monitors for close-based breaks of the most recent swing level in both the trend direction and against it.
  • HTF Fibonacci Overlay: Requests pivot data from a user-selected higher timeframe via request.security, tracks the most recent HTF swing pair, and draws a separate Fibonacci set with independent color, line style, and width controls.
  • Information Dashboard: A 2-column, 10-row table rendered on the last bar displaying trend direction, Fibonacci type, swing prices, ATR, the 61.8% level, confluence summary, HTF status, and last structure signal.


🔥 Key Features

  • Volume-Backed Confluence Zones: Each Fibonacci level that registers meaningful volume concentration is highlighted with a shaded zone box and a strength label (◆ Strong / ◇ Moderate / · Weak), so the most significant levels stand out immediately without any manual assessment.
  • Fully Configurable Fibonacci Display: Line width, label size, extension length, and individual level colors are all independently adjustable, allowing the Fibonacci overlay to be styled to suit any chart theme or personal preference.
  • BOS and CHoCH Signals with Alerts: Break of Structure and Change of Character labels are plotted directly on the bar where the break occurs, with five alert conditions covering each signal type individually and a combined catch-all.
  • Multi-Timeframe Fibonacci Overlay: Enable a second Fibonacci set from any higher timeframe (default: Daily) and display it alongside the current timeframe levels with a distinct color and line style to provide macro structural context.
  • Live On-Chart Dashboard: All key data — trend, Fibonacci direction, swing prices, ATR, the golden ratio level, confluence counts, HTF status, and last signal — is displayed in a compact table that updates on every bar close.
  • ATR Pivot Filter: The ATR multiplier filter can be tuned from 0.1 to 5.0, giving full control over how aggressively noise is filtered. Higher values produce fewer, more significant pivots suitable for higher timeframe analysis.


🎨 Visualization

  • Fibonacci Level Lines: Seven horizontal lines extend forward from the most recent swing anchor point for a configurable number of bars. Each level has its own independent color input. The 50% level is rendered as a dashed line to distinguish it from the structural levels.
  • Fibonacci Level Labels: A text label is placed at the right end of each line showing the ratio name and exact price, styled with the corresponding level color against a transparent background for chart cleanliness.
  • Confluence Zone Boxes: Where a Fibonacci level overlaps a significant volume bin, a semi-transparent shaded box spans the full line extension at the width of ATR × the tolerance multiplier. Color reflects strength: green for Strong, yellow for Moderate, grey for Weak.
  • Confluence Strength Labels: A small icon and text label (◆ Strong, ◇ Moderate, · Weak) is placed just beyond each confluence zone box, color-matched to the zone, for instant strength identification without inspecting the box fill.
  • HTF Fibonacci Lines and Labels: The higher-timeframe Fibonacci set is drawn in its own color with a selectable line style (Solid, Dashed, or Dotted) and prefixed with “HTF” in the label text to distinguish it from the current timeframe levels.
  • Pivot Markers: Confirmed swing highs are marked with a small downward triangle above the bar; confirmed swing lows with a small upward triangle below, using independently configurable colors.
  • BOS and CHoCH Labels: Structure signal labels appear directly on the signal bar — below the bar for bullish signals and above for bearish — in their respective configured colors with white text.
  • Information Dashboard: A dark-themed 2×10 table rendered in the selected corner showing all key indicator state values, with color-coded text reflecting bullish (teal), bearish (red), and neutral (grey) conditions.


📖 Usage Guidelines

Swing Pivot Detection
  • Pivot Lookback Length — Default: 10 | Range: 3–50 — Controls how many bars on each side of a candidate pivot must be lower (for highs) or higher (for lows) to confirm the pivot. Increase for fewer, more major swings; decrease for more reactive pivots.
  • ATR Period — Default: 14 | Range: 1–100 — The ATR period used to compute the minimum distance filter. A standard 14-period ATR works well for most instruments.
  • ATR Filter Multiplier — Default: 0.5 | Range: 0.1–5.0 — The minimum distance between a new pivot and the opposing swing, expressed as a multiple of ATR. Increase to require more separation and reduce noise; decrease to accept closer pivots.


Fibonacci Levels
  • Show Fibonacci Levels — Default: On — Master toggle for all Fibonacci lines and labels.
  • Fibonacci Line Extension — Default: 50 | Range: 10–200 — How many bars forward the Fibonacci lines extend from the anchor point.
  • Fibonacci Line Width — Default: 1 | Range: 1–4 — Pixel width of all Fibonacci level lines.
  • Label Size — Default: Small | Options: Tiny, Small, Normal — Size of the Fibonacci level labels.
  • Level Colors (0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%) — Independent color inputs for each level, allowing full visual customization.


Volume Profile and Confluence
  • Show Confluence Zones — Default: On — Master toggle for all confluence zone boxes and labels.
  • Volume Lookback Period — Default: 100 | Range: 20–500 — Number of historical bars included in the volume histogram. Longer lookbacks produce a more stationary profile; shorter lookbacks reflect recent volume distribution.
  • Volume Profile Bins — Default: 25 | Range: 10–50 — Number of price buckets in the histogram. More bins give finer resolution; fewer bins give broader zone detection.
  • Confluence Zone Width (ATR%) — Default: 0.5 | Range: 0.1–2.0 — Height of the shaded confluence box as a multiple of ATR. Increase for wider, more visible zones; decrease for tighter, more precise zones.
  • Strong / Moderate / Weak Confluence Colors — Independent color inputs for each confluence tier.


Multi-Timeframe Fibonacci
  • Enable HTF Fibonacci — Default: Off — Enables the higher-timeframe Fibonacci overlay.
  • Higher Timeframe — Default: D — The timeframe from which swing pivots are sourced for the HTF overlay.
  • HTF Pivot Lookback — Default: 10 | Range: 3–50 — Pivot lookback length applied on the higher timeframe.
  • HTF Fib Color — Default: Purple — Color applied to all HTF Fibonacci lines and labels.
  • HTF Line Style — Default: Dashed | Options: Solid, Dashed, Dotted — Visual style of HTF lines.
  • HTF Line Width — Default: 2 | Range: 1–4 — Pixel width of HTF Fibonacci lines.


BOS / CHoCH Detection
  • Show BOS Signals — Default: On — Displays Break of Structure labels on the chart when a continuation break is detected.
  • Show CHoCH Signals — Default: On — Displays Change of Character labels on the chart when a reversal break is detected.
  • BOS Color — Default: Blue — Color of BOS labels.
  • CHoCH Color — Default: Orange-Red — Color of CHoCH labels.


Display Settings
  • Show Pivot Markers — Default: On — Displays small triangle markers at confirmed swing highs and lows.
  • Pivot High / Low Colors — Independent color inputs for swing high and swing low markers.
  • Show Info Dashboard — Default: On — Enables the on-chart information table.
  • Dashboard Position — Default: Top Right | Options: Top Right, Top Left, Bottom Right, Bottom Left — Corner placement of the dashboard table.


✅ Best Use Cases

  • Identifying high-probability Fibonacci levels by filtering out the ones with weak volume backing and focusing entries and exits around Strong confluence zones only
  • Smart Money Concept and ICT-style analysis where BOS and CHoCH signals are used to identify trend continuation and potential reversal points within a defined swing structure
  • Multi-timeframe confluence trading where the HTF overlay is used to identify macro structure and the current timeframe levels are used for precision entries within that context
  • Swing trading on any instrument where objective, volume-backed support and resistance levels are needed without manual drawing or constant chart maintenance
  • Breakout confirmation by watching for BOS signals that occur at or near Strong confluence Fibonacci zones, providing both structural and volume-based validation


⚠️ Limitations

  • Fibonacci levels are anchored to the most recent confirmed swing pair only — historical Fibonacci sets from earlier swings are not retained on the chart
  • Volume profile accuracy depends on the lookback length relative to the current price range; on instruments with very large recent moves the profile may not fully reflect the range containing all active Fibonacci levels
  • BOS and CHoCH detection requires at least two confirmed swing highs and two confirmed swing lows before trend direction can be established — signals will not appear on the earliest bars of a chart
  • The HTF Fibonacci overlay uses lookahead enabled on historical bars to maintain visual consistency; this is standard practice for HTF overlays and does not affect current bar calculations
  • On instruments without volume data (some indices and forex pairs on certain brokers) confluence classification will produce zero-volume bins and all levels will show no confluence


💡 What Makes This Unique

  • Volume-quantified Fibonacci levels: Unlike every standard Fibonacci tool, each level is graded by actual market participation data — volume concentration — rather than by visual proximity to other technical elements
  • Noise-resistant pivot anchoring: The ATR filter ensures Fibonacci levels are only drawn from swings that represent genuine structural moves, not minor price fluctuations that create misleading retracement grids
  • Runtime-stable volume engine: The histogram is built with a direct loop and pre-allocated array rather than built-in series functions, ensuring error-free execution from bar 1 on any chart length
  • Unified structural analysis: Fibonacci retracements, volume confluence, trend structure (BOS/CHoCH), multi-timeframe context, and a live data dashboard are all integrated into a single indicator with no external dependencies


🔬 How It Works

1. Swing Pivot Detection and Filtering
  • PineScript’s pivothigh and pivotlow functions scan for candidate swing points using the configured lookback length
  • Each candidate is then tested against the ATR filter — it is only accepted if its distance from the opposing swing meets or exceeds ATR × the multiplier setting, eliminating noise and ensuring anchors represent real structure


2. Fibonacci Level Calculation
  • When a new valid pivot is confirmed, the most recent swing high and low pair is selected as the anchor, with direction set automatically based on which pivot type was most recently validated
  • The seven standard ratios are applied to the anchor range and the resulting price levels are stored in a persistent array for use by the confluence engine and dashboard


3. Volume Profile Construction
  • The lookback window is iterated bar by bar; each bar’s midpoint price is mapped to one of the configured bin slots and that bar’s volume is added to the bin’s running total
  • The array is pre-allocated at script scope with the maximum bin count and zero-filled at the start of each rebuild cycle, ensuring there are never out-of-bounds access errors regardless of when the first pivot is confirmed


4. Confluence Classification
  • Each Fibonacci level’s price is mapped to its corresponding bin index; a weighted sum of the center bin and its two neighbours is computed to smooth the reading
  • The sum is compared against the peak bin volume using three thresholds (70%, 40%, 20%) to assign a Strong, Moderate, or Weak classification, which drives both the visual zone and the dashboard count


5. Structure Signal Detection
  • After each new pivot updates the swing sequence, the last two highs and last two lows are compared to determine whether the market is in a confirmed uptrend, downtrend, or undefined structure
  • On every bar, a close-based break of the most recent swing level is tested — breaks in the trend direction fire a BOS signal; breaks against it fire a CHoCH signal — with the result fed to both chart labels and alert conditions


💡 Note:
For best results, use a Pivot Lookback Length and ATR Filter Multiplier that match the significance of swings you trade on your chosen timeframe. Lower timeframes generally benefit from smaller lookback values (5–8) and lower ATR multipliers (0.3–0.5), while higher timeframes produce cleaner results with larger values (15–20 lookback, 1.0–2.0 multiplier). Enable the HTF overlay when you want macro Fibonacci context without switching charts.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.