PROTECTED SOURCE SCRIPT

Market Structure HighLow + Liquidity [MaB]

58
๐Ÿ“Š 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

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.