PROTECTED SOURCE SCRIPT
Market Structure HighLow + Liquidity [MaB]

๐ Market Structure HighLow + Liquidity [MaB] A comprehensive indicator combining precision market structure analysis with real-time liquidity zone detection, built on a custom finite-state machine architecture.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฏ KEY FEATURES
โข Automatic Swing Detection Identifies structural High/Low points using a dual-confirmation system (minimum candles + pullback percentage)
โข Smart Trend Tracking Automatically switches between Uptrend (Higher Highs & Higher Lows) and Downtrend (Lower Highs & Lower Lows)
โข Breakout Alerts Visual markers for confirmed breakouts (Brโ / Brโ) with configurable threshold
โข Sequential Labeling Clear numbered labels (L1, H2, L3, H4...) showing the exact market structure progression
โข Color-Coded Structure Lines
โข Green: Uptrend continuation legs
โข Red: Downtrend continuation legs
โข Gray: Trend inversion points
โข Imbalance Zones (FVG) Automatically detects Fair Value Gaps that form during impulsive moves between validated swing points
โข Inducement Zones Identifies potential liquidity traps - FVGs that form before breakout confirmation, often used as stop-hunt areas
โข Dynamic Zone Management Zones automatically close when price touches them, with configurable retracement sensitivity
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฌ TECHNICAL ARCHITECTURE
This indicator does NOT rely on TradingView's built-in ta.pivothigh() / ta.pivotlow() functions.
Instead, it implements a custom finite-state machine (FSM) that manages multiple monitoring states, alternating dynamically between Uptrend and Downtrend modes based on confirmed breakouts.
Core Components:
โข State Machine Engine Multiple internal states handle candidate detection, validation, and confirmation phases. The system transitions between states based on price action triggers and confirmation criteria.
โข Dual-Confirmation System Each swing point must satisfy two independent filters before validation:
o Time-based filter (minimum candles)
o Price-based filter (minimum retracement %)
โข Directional Breakout Logic Separate breakout detection routines for uptrend continuation, downtrend continuation, and trend inversion scenarios. Each triggers specific state transitions.
โข FVG Classification Engine Automatically distinguishes between Imbalance zones (post-confirmation FVGs) and Inducement zones (pre-confirmation FVGs) based on breakout timing context.
โข Dynamic Zone Lifecycle Zones are created, monitored, and closed through a managed lifecycle with configurable touch sensitivity.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ CONFIGURABLE PARAMETERS
Market Structure
โข Analysis Start Date: Define when to begin structure analysis
โข Min Confirmation Candles: Required candles for validation (default: 3)
โข Pullback Percentage: Minimum retracement for confirmation (default: 10%)
โข Breakout Threshold: Percentage beyond structure for breakout (default: 1%)
Liquidity
โข Show Zones: Toggle visibility of imbalance and inducement zones
โข Zone Colors: Customize colors for Supply/Demand imbalances and inducements
โข Zone Retracement %: How deep price must enter zone to consider it touched (0-100%)
โข Inactive Zones Transparency: Visual distinction for closed zones
Display
โข Show Market Structure Table: Toggle info panel
โข Replay Mode: Optimize for TradingView Replay feature
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐จ ZONE COLOR CODING
โข ๐ด Imbalance Supply (Red): Bearish FVG - potential resistance/short entry
โข ๐ข Imbalance Demand (Green): Bullish FVG - potential support/long entry
โข ๐ Inducement Supply (Orange): Pre-breakout bearish FVG - possible stop-hunt zone
โข ๐ต Inducement Demand (Blue): Pre-breakout bullish FVG - possible stop-hunt zone
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก HOW IT WORKS
1. Initializes state machine in UPTREND mode, searching for first swing Low
2. Tracks price movement and triggers candidate states upon potential reversals
3. Validates candidates through dual-confirmation (time + price filters)
4. Upon confirmation, scans price range for FVG patterns (3-candle gaps)
5. Classifies detected FVGs based on breakout timing (Inducement vs Imbalance)
6. Monitors breakout levels - triggers state transitions on confirmed breaks
7. Alternates between Uptrend/Downtrend modes based on breakout direction
8. Manages zone lifecycle - closes zones when price retraces into them
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ง BEST USED FOR
โข Identifying key support/resistance levels with liquidity context
โข Spotting potential reversal zones (imbalances)
โข Avoiding stop-hunt traps (inducement awareness)
โข Trend direction confirmation
โข Breakout trading setups with confluence
โข Multi-timeframe structure and liquidity analysis
โข Understanding where institutional orders may be resting
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ NOTES
โข Works best on higher timeframes (1H+) for cleaner structure
โข Inducement zones often convert to Imbalance zones after breakout confirmation
โข Zone Retracement % allows fine-tuning: 0% = first touch, 25% = quarter penetration, 100% = full traversal
โข Inactive zones remain visible (faded) to show historical liquidity levels
โข Use Replay Mode when backtesting to prevent buffer overflow errors
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฏ KEY FEATURES
โข Automatic Swing Detection Identifies structural High/Low points using a dual-confirmation system (minimum candles + pullback percentage)
โข Smart Trend Tracking Automatically switches between Uptrend (Higher Highs & Higher Lows) and Downtrend (Lower Highs & Lower Lows)
โข Breakout Alerts Visual markers for confirmed breakouts (Brโ / Brโ) with configurable threshold
โข Sequential Labeling Clear numbered labels (L1, H2, L3, H4...) showing the exact market structure progression
โข Color-Coded Structure Lines
โข Green: Uptrend continuation legs
โข Red: Downtrend continuation legs
โข Gray: Trend inversion points
โข Imbalance Zones (FVG) Automatically detects Fair Value Gaps that form during impulsive moves between validated swing points
โข Inducement Zones Identifies potential liquidity traps - FVGs that form before breakout confirmation, often used as stop-hunt areas
โข Dynamic Zone Management Zones automatically close when price touches them, with configurable retracement sensitivity
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฌ TECHNICAL ARCHITECTURE
This indicator does NOT rely on TradingView's built-in ta.pivothigh() / ta.pivotlow() functions.
Instead, it implements a custom finite-state machine (FSM) that manages multiple monitoring states, alternating dynamically between Uptrend and Downtrend modes based on confirmed breakouts.
Core Components:
โข State Machine Engine Multiple internal states handle candidate detection, validation, and confirmation phases. The system transitions between states based on price action triggers and confirmation criteria.
โข Dual-Confirmation System Each swing point must satisfy two independent filters before validation:
o Time-based filter (minimum candles)
o Price-based filter (minimum retracement %)
โข Directional Breakout Logic Separate breakout detection routines for uptrend continuation, downtrend continuation, and trend inversion scenarios. Each triggers specific state transitions.
โข FVG Classification Engine Automatically distinguishes between Imbalance zones (post-confirmation FVGs) and Inducement zones (pre-confirmation FVGs) based on breakout timing context.
โข Dynamic Zone Lifecycle Zones are created, monitored, and closed through a managed lifecycle with configurable touch sensitivity.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ CONFIGURABLE PARAMETERS
Market Structure
โข Analysis Start Date: Define when to begin structure analysis
โข Min Confirmation Candles: Required candles for validation (default: 3)
โข Pullback Percentage: Minimum retracement for confirmation (default: 10%)
โข Breakout Threshold: Percentage beyond structure for breakout (default: 1%)
Liquidity
โข Show Zones: Toggle visibility of imbalance and inducement zones
โข Zone Colors: Customize colors for Supply/Demand imbalances and inducements
โข Zone Retracement %: How deep price must enter zone to consider it touched (0-100%)
โข Inactive Zones Transparency: Visual distinction for closed zones
Display
โข Show Market Structure Table: Toggle info panel
โข Replay Mode: Optimize for TradingView Replay feature
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐จ ZONE COLOR CODING
โข ๐ด Imbalance Supply (Red): Bearish FVG - potential resistance/short entry
โข ๐ข Imbalance Demand (Green): Bullish FVG - potential support/long entry
โข ๐ Inducement Supply (Orange): Pre-breakout bearish FVG - possible stop-hunt zone
โข ๐ต Inducement Demand (Blue): Pre-breakout bullish FVG - possible stop-hunt zone
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก HOW IT WORKS
1. Initializes state machine in UPTREND mode, searching for first swing Low
2. Tracks price movement and triggers candidate states upon potential reversals
3. Validates candidates through dual-confirmation (time + price filters)
4. Upon confirmation, scans price range for FVG patterns (3-candle gaps)
5. Classifies detected FVGs based on breakout timing (Inducement vs Imbalance)
6. Monitors breakout levels - triggers state transitions on confirmed breaks
7. Alternates between Uptrend/Downtrend modes based on breakout direction
8. Manages zone lifecycle - closes zones when price retraces into them
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ง BEST USED FOR
โข Identifying key support/resistance levels with liquidity context
โข Spotting potential reversal zones (imbalances)
โข Avoiding stop-hunt traps (inducement awareness)
โข Trend direction confirmation
โข Breakout trading setups with confluence
โข Multi-timeframe structure and liquidity analysis
โข Understanding where institutional orders may be resting
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ NOTES
โข Works best on higher timeframes (1H+) for cleaner structure
โข Inducement zones often convert to Imbalance zones after breakout confirmation
โข Zone Retracement % allows fine-tuning: 0% = first touch, 25% = quarter penetration, 100% = full traversal
โข Inactive zones remain visible (faded) to show historical liquidity levels
โข Use Replay Mode when backtesting to prevent buffer overflow errors
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations โ learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations โ learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.