OPEN-SOURCE SCRIPT
Ultimate Market Structure [Alpha Extract]

Ultimate Market Structure [Alpha Extract]
A comprehensive market structure analysis tool that combines advanced swing point detection, imbalance zone identification, and intelligent break analysis to identify high-probability trading opportunities.Utilizing a sophisticated trend scoring system, this indicator classifies market conditions and provides clear signals for structure breaks, directional changes, and fair value gap detection with institutional-grade precision.
🔶 Advanced Swing Point Detection
Pine Script®
🔶 Significance Scoring System
🔶 Comprehensive Trend Analysis
Pine Script®
❓How It Works
🔶 Imbalance Zone Detection
Pine Script®
🔶 Structure Break Analysis

🔶 Intelligent Zone Management
🔶Liquidity Zone Detection
🔶 Visual Structure Mapping
🔶 Market Structure Interpretation

🔶 Performance Optimization
Why Choose Ultimate Market Structure [Alpha Extract]?
This indicator provides traders with institutional-grade market structure analysis, combining multiple analytical approaches into one comprehensive tool. By identifying key structure levels, imbalance zones, and break patterns with advanced significance scoring, it helps traders understand market dynamics and position themselves for high-probability trade setups in alignment with smart money concepts. The sophisticated trend scoring system and intelligent zone management make it an essential tool for any serious trader looking to decode market structure with precision and confidence.
A comprehensive market structure analysis tool that combines advanced swing point detection, imbalance zone identification, and intelligent break analysis to identify high-probability trading opportunities.Utilizing a sophisticated trend scoring system, this indicator classifies market conditions and provides clear signals for structure breaks, directional changes, and fair value gap detection with institutional-grade precision.
🔶 Advanced Swing Point Detection
- Identifies pivot highs and lows using configurable lookback periods with optional close-based analysis for cleaner signals. The system automatically labels swing points as Higher Highs (HH), Lower Highs (LH), Higher Lows (HL), and Lower Lows (LL) while providing advanced classifications including "rising_high", "falling_high", "rising_low", "falling_low", "peak_high", and "valley_low" for nuanced market analysis.
swingHighPrice = useClosesForStructure ? ta.pivothigh(close, swingLength, swingLength) : ta.pivothigh(high, swingLength, swingLength)
swingLowPrice = useClosesForStructure ? ta.pivotlow(close, swingLength, swingLength) : ta.pivotlow(low, swingLength, swingLength)
classification = classifyStructurePoint(structureHighPrice, upperStructure, true)
significance = calculateSignificance(structureHighPrice, upperStructure, true)
🔶 Significance Scoring System
- Each structure point receives a significance level on a 1-5 scale based on its distance from previous points, helping prioritize the most important levels. This intelligent scoring system ensures traders focus on the most meaningful structure breaks while filtering out minor noise.
🔶 Comprehensive Trend Analysis
- Calculates momentum, strength, direction, and confidence levels using volatility-normalized price changes and multi-timeframe correlation. The system provides real-time trend state tracking with bullish (+1), bearish (-1), or neutral (0) direction assessment and 0-100 confidence scoring.
// Calculate trend momentum using rate of change and volatility
calculateTrendMomentum(lookback) =>
priceChange = (close - close[lookback]) / close[lookback] * 100
avgVolatility = ta.atr(lookback) / close * 100
momentum = priceChange / (avgVolatility + 0.0001)
momentum
// Calculate trend strength using multiple timeframe correlation
calculateTrendStrength(shortPeriod, longPeriod) =>
shortMA = ta.sma(close, shortPeriod)
longMA = ta.sma(close, longPeriod)
separation = math.abs(shortMA - longMA) / longMA * 100
strength = separation * slopeAlignment
❓How It Works
🔶 Imbalance Zone Detection
- Identifies Fair Value Gaps (FVGs) between consecutive candles where price gaps create unfilled areas. These zones are displayed as semi-transparent boxes with optional center line mitigation tracking, highlighting potential support and resistance levels where institutional players often react.
// Detect Fair Value Gaps
detectPriceImbalance() =>
currentHigh = high
currentLow = low
refHigh = high[2]
refLow = low[2]
if currentOpen > currentClose
if currentHigh - refLow < 0
upperBound = currentClose - (currentClose - refLow)
lowerBound = currentClose - (currentClose - currentHigh)
centerPoint = (upperBound + lowerBound) / 2
newZone = ImbalanceZone.new(
zoneBox = box.new(bar_index, upperBound, rightEdge, lowerBound,
bgcolor=bullishImbalanceColor, border_color=hiddenColor)
)
🔶 Structure Break Analysis
- Determines Break of Structure (BOS) for trend continuation and Directional Change (DC) for trend reversals with advanced classification as "continuation", "reversal", or "neutral". The system compares pre-trend and post-trend states for each break, providing comprehensive trend change momentum analysis.
🔶 Intelligent Zone Management
- Features partial mitigation tracking when price enters but doesn't fully fill zones, with automatic zone boundary adjustment during partial fills. Smart array management keeps only recent structure points for optimal performance while preventing duplicate signals from the same level.
🔶Liquidity Zone Detection
- Automatically identifies potential liquidity zones at key structure points for institutional trading analysis. The system tracks broken structure points and provides adaptive zone extension with configurable time-based limits for imbalance areas.
🔶 Visual Structure Mapping
- Provides clear visual indicators including swing labels with color-coded significance levels, dashed lines connecting break points with BOS/DC labels, and break signals for continuation and reversal patterns. The adaptive zones feature smart management with automatic mitigation tracking.
🔶 Market Structure Interpretation
- HH/HL patterns indicate bullish market structure with trend continuation likelihood, while LH/LL patterns signal bearish structure with downtrend continuation expected. BOS signals represent structure breaks in trend direction for continuation opportunities, while DC signals warn of potential reversals.
🔶 Performance Optimization
- Automatic cleanup of old structure points (keeps last 8 points), recent break tracking (keeps last 5 break events), and efficient array management ensure smooth performance across all timeframes and market conditions.
Why Choose Ultimate Market Structure [Alpha Extract]?
This indicator provides traders with institutional-grade market structure analysis, combining multiple analytical approaches into one comprehensive tool. By identifying key structure levels, imbalance zones, and break patterns with advanced significance scoring, it helps traders understand market dynamics and position themselves for high-probability trade setups in alignment with smart money concepts. The sophisticated trend scoring system and intelligent zone management make it an essential tool for any serious trader looking to decode market structure with precision and confidence.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Access more of our systems and insights at alphaextract.xyz
All analysis provided by Alpha Extract is for educational and informational purposes only.
All analysis provided by Alpha Extract is for educational and informational purposes only.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Access more of our systems and insights at alphaextract.xyz
All analysis provided by Alpha Extract is for educational and informational purposes only.
All analysis provided by Alpha Extract is for educational and informational purposes only.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.