Internal vs External Liquidity Zones [Alpha Extract]A sophisticated dual-timeframe market structure visualization system that identifies and maps internal (short-term) and external (long-term) liquidity levels with comprehensive Break of Structure (BOS) and Change of Character (CHoCH) detection across both timeframes. Utilizing pivot-based zone creation with ATR-scaled heights and sweep classification, this indicator delivers institutional-grade liquidity mapping distinguishing between major swing liquidity (external) and minor retracement liquidity (internal) for multi-dimensional market structure analysis. The system's hierarchical structure framework combined with objective arrow projection and state-based zone coloring provides complete smart money concept implementation for advanced order flow trading.
🔶 Understanding Internal vs External Structure
External Structure represents major swing points using longer pivot lengths (default 10 bars), identifying significant highs and lows that define the broader market range and trend direction. These are the key levels where large institutional positions likely exist, stop losses cluster, and major trend reversals may occur. External structure breaks (eBOS/eCHoCH) signal significant shifts in market sentiment and often precede sustained directional moves.
Internal Structure captures minor swing points within the external range using shorter pivot lengths (default 3 bars), revealing short-term liquidity pools formed during retracements, consolidations, and minor corrections. These represent areas where smaller participants' stops accumulate and where price often reacts before continuing toward external objectives. Internal structure breaks (iBOS/iCHoCH) provide early warning signals and tactical entry opportunities within the broader external trend context.
The relationship between internal and external structure creates a hierarchical framework: external zones define the "what" (overall bias and major objectives), while internal zones reveal the "how" (tactical path and entry models). When internal structure breaks bullish while within an external bearish range, it signals potential reversal setup. When internal breaks align with external direction, it confirms trend strength.
🔶 Advanced Dual-Pivot Detection Framework
Implements separate pivot calculation systems for external and internal structure with configurable lookback periods optimizing for different swing magnitudes. The system identifies external pivots using extended length capturing major swing extremes, detects internal pivots using compressed length for minor retracement highs/lows, and optionally requires internal pivots occur within current external range boundaries ensuring hierarchical structure coherence.
// Dual Structure Detection
External_Pivot_High = ta.pivothigh(high, External_Length, External_Length)
External_Pivot_Low = ta.pivotlow(low, External_Length, External_Length)
Internal_Pivot_High = ta.pivothigh(high, Internal_Length, Internal_Length)
Internal_Pivot_Low = ta.pivotlow(low, Internal_Length, Internal_Length)
// Optional Range Requirement
Valid_Internal = requireInside ? (pivot within ) : true
🔶 BOS and CHoCH Detection System
Break of Structure (BOS) occurs when price breaks a recent structure point in the direction of the current trend, confirming trend continuation. The system identifies BOS when:
Price breaks above previous high while trend remains bullish (bullish BOS)
Price breaks below previous low while trend remains bearish (bearish BOS)
Previous structure point hasn't been violated yet
Change of Character (CHoCH) signals potential trend reversal when price breaks structure counter to the established trend direction. The system detects CHoCH when:
Price breaks above previous high while trend was bearish (bullish CHoCH - reversal signal)
Price breaks below previous low while trend was bullish (bearish CHoCH - reversal signal)
Both external (e-prefix) and internal (i-prefix) structures generate independent BOS/CHoCH labels, enabling multi-timeframe structure analysis where eCHoCH may signal major reversal while iBOS confirms minor trend within that reversal.
🔶 Intelligent Zone Creation Architecture
Features ATR-based or tick-based zone height calculation with separate sizing for internal and external liquidity levels, creating visual boxes centered on pivot points. The system calculates zone dimensions using configurable ATR multiples (default 0.40x) or fixed tick counts, positions zones symmetrically above/below pivot levels, and applies distinct color schemes distinguishing external highs (red), external lows (white), internal highs (cyan), and internal lows (blue).
🔶 Equal High/Low Detection Mode
Provides advanced internal zone mode that only creates zones when consecutive internal pivots form equal highs or equal lows within ATR-based tolerance, filtering noise and highlighting significant accumulation/distribution patterns. The system tracks previous internal pivots, compares new pivots against tolerance threshold, creates averaged zone when equality detected, and ignores isolated pivots that don't form patterns, reducing visual clutter while emphasizing institutional liquidity clustering.
🔶 Comprehensive Sweep Classification System
Implements three sweep detection modes distinguishing between liquidity grabs and genuine breakouts with state-based zone coloring:
Wick Mode: Marks zone as swept when wick touches but close remains outside
Close Mode: Requires close through zone for sweep classification
Wick+Close Classify Mode: Distinguishes sweeps (S - wick touches, close outside) from breaks (B - close through zone)
The system transitions zones through three states: Active (0 - untouched), Swept (1 - liquidity grabbed), Broken (2 - fully breached), applying progressive transparency increases to visually distinguish state changes and enabling traders to identify false breakouts versus genuine structural violations.
🔶 Objective Arrow Projection Framework
Features intelligent objective labeling that triggers when internal zones are swept, projecting arrows pointing toward opposite external structure as probable targets. The system generates "->ExtH" labels when internal low swept (suggesting move toward external high) and "->ExtL" labels when internal high swept (suggesting move toward external low), providing smart money concept implementation where internal liquidity grabs often precede runs toward external objectives.
🔶 Dynamic Zone Management System
Maintains separate arrays for external and internal zones with configurable history modes and maximum zone limits. The system implements "Latest Only" mode (clears previous external zones of same side when new pivot detected) or "Keep History" mode (preserves all zones up to maximum limit), automatically expires oldest zones when limits reached, and optionally clears all internal zones when new external pivot forms, maintaining clean chart presentation while preserving relevant liquidity context.
🔶 Trend Momentum Scoring Engine
Calculates sophisticated trend state using dual-component analysis combining momentum (price change normalized by volatility) with strength (MA separation and slope alignment). The system generates TrendScore objects containing momentum value, strength percentage, direction (-1/0/+1), and confidence score (0-100), uses these scores to classify BOS versus CHoCH by comparing previous and current trend states, and provides objective structural classification beyond simple price level violations.
🔶 Adaptive Zone Extension Logic
Implements intelligent right-edge management where active zones extend to current bar but freeze at touch/sweep point when cut-on-touch enabled. The system continuously updates zone right boundaries during active state, locks boundary at bar of first violation, and maintains locked position through subsequent bars, creating visual history of when liquidity was accessed while preventing misleading forward projection of filled zones.
🔶 Multi-State Visual Feedback System
Provides comprehensive color and transparency modulation based on zone state with two visual style options. "Soft Fill" mode uses semi-transparent fills with subtle borders, while "Outline" mode displays only colored borders with transparent fills. The system applies progressive transparency increases: Active (light), Swept (medium), Broken (heavy), with independent control over fill and border transparency enabling customization from subtle hints to prominent highlighting.
🔶 Structure Line Visualization Architecture
Creates dashed horizontal lines connecting structure break points to current bar with BOS/CHoCH labels positioned at midpoint between break bar and detection bar. The system draws lines at exact structure level, applies color coding matching bullish (green) or bearish (red) classification, and uses compact labels (eBOS, eCHoCH, iBOS, iCHoCH) for instant structural event identification without cluttering chart with excessive text.
🔶 Performance Optimization Framework
Utilizes efficient array management with configurable maximum limits (default 120 zones each type), automatic cleanup of oldest elements, and optional hiding of filled zones reducing active object count. The system includes intelligent state tracking minimizing recalculation overhead, optimized sweep detection using simple comparison logic, and streamlined zone update loops processing only active zones for consistent performance across extended sessions.
🔶 Why Choose Internal vs External Liquidity Zones ?
This indicator delivers institutional-grade market structure analysis through hierarchical dual-timeframe liquidity mapping with comprehensive BOS/CHoCH detection. The distinction between external (major swing) and internal (minor retracement) structure provides complete smart money concept implementation where external zones define bias and targets while internal zones reveal tactical entries and stop hunts. The system's sweep classification distinguishes liquidity grabs from genuine breakouts, objective arrows project probable targets based on internal sweeps toward external levels, and comprehensive BOS/CHoCH labeling across both timeframes enables multi-dimensional structural analysis. Perfect for order flow traders implementing ICT concepts, liquidity-based strategies, or market maker models in cryptocurrency, forex, and futures markets where understanding the relationship between internal accumulation and external objectives is essential for high-probability trade location and proper risk management.
مؤشر Pine Script®






















