OPEN-SOURCE SCRIPT
מעודכן

Fractal Exhaustion Band [QuantAlgo]

22 804
🟢 Overview

The Fractal Exhaustion Band is a trend-following indicator that replaces the fixed ATR multiplier common to most adaptive bands with the Fractal Dimension Index, scaling the buffer width in real time based on how efficiently price is consuming its recent range. Additionally, an extremum tracker accumulates swing highs and lows since the last confirmed flip to form an outer Band Edge, giving traders a structured range to position within the trend, identify exhaustion near its boundaries, and treat extensions beyond the edge as potential deviation signals ahead of a directional flip across any instrument or timeframe.
תמונת-בזק
🟢 How It Works

The core methodology is built around three sequential stages: a fractal dimension calculation that quantifies the structural quality of recent price movement, a dynamic buffer derived from that measurement, and a ratcheting trend line that advances only when market conditions justify it.

First, the Fractal Dimension Index (FDI) is calculated by comparing the total path length price has travelled over the lookback window against the straight-line distance between its highest and lowest point. A value near 1 indicates clean, efficient trending. A value near 2 indicates erratic, space-filling movement. The ratio is log-normalised by the window size to keep it comparable across different FDI Period settings:
Pine Script®

Next, the FDI is fed directly into the buffer calculation as a scaling factor on top of the Band Width Multiplier and a 10-period ATR. This means the buffer is never fixed; it inflates when price behaviour is erratic and compresses when price is trending with conviction:
Pine Script®

The trend line then ratchets in the direction of the current trend, but only on bars where the FDI is below 1.5. This gate prevents the line from being dragged by price during high-fractal-dimension conditions, even if price has not yet breached the buffer threshold. A trend flip is only registered when price closes beyond the buffer on the opposite side:
Pine Script®

Finally, an extremum tracker accumulates the running high or low since the last confirmed flip, forming the outer Band Edge. A midline is derived as the average between this extremum and the trend line, creating a three-layer structure that encodes both the structural anchor of recent price extremes and the adaptive trend line beneath it:
Pine Script®

תמונת-בזק
🟢 Signal Interpretation

▶ Bullish Trend (Band Rising with Bullish Colour): When price moves upward with sufficient efficiency to produce a low FDI reading and close above the trend line's buffer threshold, the trend direction flips to bullish and the entire band shifts to the bullish colour. From that point, the Fractal Line ratchets upward on each bar where the FDI remains below 1.5, while the extremum tracker accumulates successive highs to form the outer Band Edge above. The flat segments visible in the band reflect bars where the FDI gate suppressed movement, while upward steps reflect bars where trending conditions were confirmed.
תמונת-בזק
Within the bullish band, the Fractal Line and Band Edge define a structured trading range. Price oscillating between the two represents normal trend continuation behaviour, and pullbacks toward the Fractal Line can be treated as higher-probability long entries with the trend, using the Fractal Line itself as the logical invalidation level. The Band Mid serves as a directional gauge within that range; price holding above it reflects stronger momentum, while price drifting below it signals weakening conviction worth monitoring. When price pushes into the Band Edge zone and begins interacting with the accumulated swing highs, treat that as an exhaustion area rather than a continuation signal. Longs initiated near the Band Edge carry elevated risk of a short-term mean reversion back toward the Fractal Line. If price then extends meaningfully beyond the Band Edge, treat the extension as a deviation from the established structure. A deviation of this kind, particularly when accompanied by a rising FDI indicating deteriorating trend quality, is a preparatory signal to begin tightening long exposure and watching for the Fractal Line to be breached on the downside, which would confirm the bias flip to bearish.

▶ Bearish Trend (Band Declining with Bearish Colour): When price moves downward with sufficient efficiency to produce a low FDI reading and close below the trend line's buffer threshold, the trend direction flips to bearish and the band shifts to the bearish colour. The Fractal Line ratchets lower on each bar where the FDI gate permits, while the extremum tracker accumulates successive lows to form the outer Band Edge below. As with the bullish state, the filter holds its last value on bars where fractal dimension is elevated, and the direction state remains unchanged on those bars.
תמונת-בזק
Within the bearish band, the same structural logic applies in reverse. Price oscillating between the Fractal Line above and the Band Edge below represents normal bearish continuation, and bounces toward the Fractal Line can be treated as higher-probability short entries with the trend, using the Fractal Line as the invalidation level. The Band Mid again acts as a momentum gauge; price holding below it indicates sustained selling pressure, while recovery above it suggests the downtrend is losing conviction. When price pushes into the Band Edge zone and interacts with the accumulated swing lows, treat that region as exhaustion rather than confirmation of further downside. Shorts initiated near the Band Edge carry elevated mean-reversion risk back toward the Fractal Line. If price extends beyond the Band Edge to the downside, treat that extension as a structural deviation. A deviation paired with a rising FDI is a signal to begin reducing short exposure and watching for an upward breach of the Fractal Line, which would confirm the directional flip back to bullish.

🟢 Features

▶ Preconfigured Presets: Three parameter sets cover a range of trading styles and timeframes. "Default" delivers balanced noise filtering suited to swing trading on 4-hour and daily charts. "Fast Response" tightens the buffer and shortens the fractal measurement window for intraday and scalping use on 1-minute to 1-hour charts, producing earlier trend flips in response to smaller directional moves. "Smooth Trend" widens the buffer and extends the measurement window for position trading on daily and weekly charts, requiring a more sustained and efficient directional move before a trend flip is registered.
תמונת-בזק
▶ Built-in Alerts: Three alert conditions support automated monitoring of trend transitions. Bullish Trend fires on the first bar where trend direction flips from bearish to bullish. Bearish Trend fires on the first bar where trend direction flips from bullish to bearish. Any Signal Change triggers on either transition for traders who want a single unified alert regardless of direction. All alerts include the exchange, ticker, and timeframe in the message for immediate context.
תמונת-בזק
▶ Visual Customisation: Six colour presets (Classic, Aqua, Cosmic, Cyber, Neon, and Custom) provide coordinated bullish and bearish colour pairings suited to different chart themes and personal preferences. Selecting Custom exposes independent colour pickers for full manual control over both states. The three-layer band fill uses graduated transparency across the outer edge, midline, and trend line zones to clearly distinguish structural from adaptive components at a glance. Optional bar colouring tints price candles with the active trend colour using a configurable transparency level, and optional background colouring extends the trend state tint across the full chart pane at a separately configurable transparency.
תמונת-בזק
הערות שחרור
Added fill visibility toggle. The band fill can now be shown or hidden independently of the band lines.

כתב ויתור

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