OPEN-SOURCE SCRIPT
Market Structure by GreenSquad

Market Structure
This indicator maps price structure using confirmed swing pivots rather than candle closes.
Swings are validated using a symmetric lookback window, meaning a high or low is only accepted after both left and right side confirmation. This avoids repainting and ensures structure reflects actual auction completion instead of intrabar noise.
Each new pivot is classified relative to the previous one:
Higher High (HH) → continuation strength
Higher Low (HL) → bullish pullback
Lower High (LH) → bearish pullback
Lower Low (LL) → continuation weakness
From these sequences a persistent market state is derived:
HH following HL → Bullish trend
LL following LH → Bearish trend
Opposite break → Change of Character (transition phase)
No progression → Range environment
A zig-zag backbone connects confirmed pivots to visualize the true path of price movement.
Additionally, the indicator measures volatility using ATR relative to its average:
Expansion → impulsive conditions, breakouts more likely
Compression → contraction, expansion likely upcoming
The dashboard summarizes:
market state, last structural event, volatility regime, and statistically favorable trading bias (pullbacks in trend, reversals in transition).
The tool is designed as a context filter — not a signal generator — helping traders align entries with confirmed auction structure rather than reacting to individual candles.
This indicator maps price structure using confirmed swing pivots rather than candle closes.
Swings are validated using a symmetric lookback window, meaning a high or low is only accepted after both left and right side confirmation. This avoids repainting and ensures structure reflects actual auction completion instead of intrabar noise.
Each new pivot is classified relative to the previous one:
Higher High (HH) → continuation strength
Higher Low (HL) → bullish pullback
Lower High (LH) → bearish pullback
Lower Low (LL) → continuation weakness
From these sequences a persistent market state is derived:
HH following HL → Bullish trend
LL following LH → Bearish trend
Opposite break → Change of Character (transition phase)
No progression → Range environment
A zig-zag backbone connects confirmed pivots to visualize the true path of price movement.
Additionally, the indicator measures volatility using ATR relative to its average:
Expansion → impulsive conditions, breakouts more likely
Compression → contraction, expansion likely upcoming
The dashboard summarizes:
market state, last structural event, volatility regime, and statistically favorable trading bias (pullbacks in trend, reversals in transition).
The tool is designed as a context filter — not a signal generator — helping traders align entries with confirmed auction structure rather than reacting to individual candles.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
May the Green Spirit be with You ❇️💚
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
May the Green Spirit be with You ❇️💚
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.