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.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔬 HOW THE ALGORITHM WORKS
1. Swing Point Detection Logic
Unlike simple pivot-based indicators, this script uses a custom state machine that tracks price action in real-time:
Candidate Detection: When price makes a new high, the algorithm waits for a candle to CLOSE below the low of that high candle. This "close below trigger" initiates a candidate state.
Dual Confirmation System: A candidate becomes a validated swing point only when BOTH conditions are met:
Time Filter: A minimum number of candles must pass (configurable, default: 5)
Price Filter: Price must retrace by a minimum percentage of the previous leg's range (configurable, default: 10%)
Dynamic Threshold Adjustment: When the current leg amplitude exceeds 2.5× the average of the last 20 legs, the algorithm automatically relaxes confirmation filters to avoid missing extended moves.
2. Trend State Machine
The indicator maintains an internal trend state (Uptrend/Downtrend) that determines how price action is interpreted:
Uptrend Mode: Searches for Higher Highs and Higher Lows. A confirmed High triggers monitoring for breakout above that level.
Downtrend Mode: Searches for Lower Highs and Lower Lows. A confirmed Low triggers monitoring for breakdown below that level.
Trend Inversion: When price closes beyond the opposite structure point by the Breakout Threshold %, the trend state flips and the search pattern reverses.
3. FVG (Fair Value Gap) Detection
The algorithm scans for 3-candle patterns where a gap exists between candle 1's high/low and candle 3's low/high:
Bullish FVG: low[0] > high[2] AND close[1] > high[2] — gap above, indicating buying pressure
Bearish FVG: high[0] < low[2] AND close[1] < low[2] — gap below, indicating selling pressure
4. Imbalance vs Inducement Classification
This is the key innovation of this indicator:
Inducement Zone: An FVG detected BEFORE the next structural breakout is confirmed. These often act as liquidity traps where stops are hunted before the real move.
Imbalance Zone: An FVG that survives until breakout confirmation. When price breaks structure, the last active Inducement converts to an Imbalance, signaling a validated supply/demand zone.
Detection Flow:
High Confirmed → Start scanning for FVGs → Each FVG = Inducement
↓
Breakout Confirmed → Last Inducement → Imbalance
5. Zone Touch Detection
Zones are monitored each bar. A zone is considered "touched" when:
Supply Zone: high >= zone_bottom + (zone_height × retracement%)
Demand Zone: low <= zone_top - (zone_height × retracement%)
At 0% retracement, first contact closes the zone. At 100%, price must fully traverse it.
6. Zone Size Filter
To avoid noise from insignificant zones, the algorithm maintains a rolling average of the last 50 zone heights:
Zones smaller than (100% - tolerance%) of the average are rejected
With default 85% tolerance: zones below 15% of average size are filtered out
Large zones are always accepted regardless of size
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ PARAMETERS EXPLAINED
Market Structure
Min Confirmation Candles (default: 5) — Bars required after candidate detection
Pullback Percentage (default: 10%) — Minimum retracement of leg range
Breakout Threshold (default: 1%) — Distance beyond structure for confirmed break
Liquidity
Zone Size Tolerance (default: 85%) — Filters zones smaller than 15% of average size
Min Zones for Average (default: 10) — Zones needed before size filter activates
Zone Retracement (default: 0%) — How deep price must enter to invalidate zone
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎨 VISUAL GUIDE
Structure Lines:
🟢 Green = Uptrend leg (L→H in uptrend)
🔴 Red = Downtrend leg (H→L in downtrend)
⚪ Gray = Trend inversion point
Zone Colors:
🔴 Red = Imbalance Supply (validated resistance)
🟢 Green = Imbalance Demand (validated support)
🟠 Orange = Inducement Supply (potential bull trap)
🔵 Blue = Inducement Demand (potential bear trap)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 PRACTICAL USAGE
Trend Following: Trade in direction of colored lines (green = long bias, red = short bias)
Zone Entries: Look for price returning to Imbalance zones for high-probability entries
Trap Avoidance: Inducement zones warn of potential stop-hunts before real moves
Breakout Confirmation: Wait for "Br↑" or "Br↓" labels before entering breakout trades
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ NOTES
Best on 1H+ timeframes for cleaner structure
Inducements often convert to Imbalances after breakout
Use Replay Mode when backtesting to prevent buffer errors
Faded zones show historical levels that have been touched
A comprehensive indicator combining precision market structure analysis with real-time liquidity zone detection.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔬 HOW THE ALGORITHM WORKS
1. Swing Point Detection Logic
Unlike simple pivot-based indicators, this script uses a custom state machine that tracks price action in real-time:
Candidate Detection: When price makes a new high, the algorithm waits for a candle to CLOSE below the low of that high candle. This "close below trigger" initiates a candidate state.
Dual Confirmation System: A candidate becomes a validated swing point only when BOTH conditions are met:
Time Filter: A minimum number of candles must pass (configurable, default: 5)
Price Filter: Price must retrace by a minimum percentage of the previous leg's range (configurable, default: 10%)
Dynamic Threshold Adjustment: When the current leg amplitude exceeds 2.5× the average of the last 20 legs, the algorithm automatically relaxes confirmation filters to avoid missing extended moves.
2. Trend State Machine
The indicator maintains an internal trend state (Uptrend/Downtrend) that determines how price action is interpreted:
Uptrend Mode: Searches for Higher Highs and Higher Lows. A confirmed High triggers monitoring for breakout above that level.
Downtrend Mode: Searches for Lower Highs and Lower Lows. A confirmed Low triggers monitoring for breakdown below that level.
Trend Inversion: When price closes beyond the opposite structure point by the Breakout Threshold %, the trend state flips and the search pattern reverses.
3. FVG (Fair Value Gap) Detection
The algorithm scans for 3-candle patterns where a gap exists between candle 1's high/low and candle 3's low/high:
Bullish FVG: low[0] > high[2] AND close[1] > high[2] — gap above, indicating buying pressure
Bearish FVG: high[0] < low[2] AND close[1] < low[2] — gap below, indicating selling pressure
4. Imbalance vs Inducement Classification
This is the key innovation of this indicator:
Inducement Zone: An FVG detected BEFORE the next structural breakout is confirmed. These often act as liquidity traps where stops are hunted before the real move.
Imbalance Zone: An FVG that survives until breakout confirmation. When price breaks structure, the last active Inducement converts to an Imbalance, signaling a validated supply/demand zone.
Detection Flow:
High Confirmed → Start scanning for FVGs → Each FVG = Inducement
↓
Breakout Confirmed → Last Inducement → Imbalance
5. Zone Touch Detection
Zones are monitored each bar. A zone is considered "touched" when:
Supply Zone: high >= zone_bottom + (zone_height × retracement%)
Demand Zone: low <= zone_top - (zone_height × retracement%)
At 0% retracement, first contact closes the zone. At 100%, price must fully traverse it.
6. Zone Size Filter
To avoid noise from insignificant zones, the algorithm maintains a rolling average of the last 50 zone heights:
Zones smaller than (100% - tolerance%) of the average are rejected
With default 85% tolerance: zones below 15% of average size are filtered out
Large zones are always accepted regardless of size
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ PARAMETERS EXPLAINED
Market Structure
Min Confirmation Candles (default: 5) — Bars required after candidate detection
Pullback Percentage (default: 10%) — Minimum retracement of leg range
Breakout Threshold (default: 1%) — Distance beyond structure for confirmed break
Liquidity
Zone Size Tolerance (default: 85%) — Filters zones smaller than 15% of average size
Min Zones for Average (default: 10) — Zones needed before size filter activates
Zone Retracement (default: 0%) — How deep price must enter to invalidate zone
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎨 VISUAL GUIDE
Structure Lines:
🟢 Green = Uptrend leg (L→H in uptrend)
🔴 Red = Downtrend leg (H→L in downtrend)
⚪ Gray = Trend inversion point
Zone Colors:
🔴 Red = Imbalance Supply (validated resistance)
🟢 Green = Imbalance Demand (validated support)
🟠 Orange = Inducement Supply (potential bull trap)
🔵 Blue = Inducement Demand (potential bear trap)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 PRACTICAL USAGE
Trend Following: Trade in direction of colored lines (green = long bias, red = short bias)
Zone Entries: Look for price returning to Imbalance zones for high-probability entries
Trap Avoidance: Inducement zones warn of potential stop-hunts before real moves
Breakout Confirmation: Wait for "Br↑" or "Br↓" labels before entering breakout trades
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ NOTES
Best on 1H+ timeframes for cleaner structure
Inducements often convert to Imbalances after breakout
Use Replay Mode when backtesting to prevent buffer errors
Faded zones show historical levels that have been touched
Script protetto
Questo script è pubblicato come codice protetto. Tuttavia, è possibile utilizzarle liberamente e senza alcuna limitazione – ulteriori informazioni qui.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script protetto
Questo script è pubblicato come codice protetto. Tuttavia, è possibile utilizzarle liberamente e senza alcuna limitazione – ulteriori informazioni qui.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.