OPEN-SOURCE SCRIPT
[eLm] 0-1-2

# 📈 Market Structure Indicator – Counter System
This indicator dynamically analyzes price action to detect key market structure shifts and trend strength using four essential formations:
## 🔍 Detected Structures
- **Higher High (HH):** A candle forming a new high above recent peaks
- **Lower Low (LL):** A candle forming a new low below recent bottoms
- **Higher Low (HL):** A higher dip, indicating potential trend continuation
- **Lower High (LH):** A lower peak, signaling potential weakness
## 🧠 Structure Protection Logic
After a HH or LL is formed, if price does not breach that level within a user-defined number of candles, the level is considered **"protected."**
This provides insight into trend strength and market reaction.
## 🔢 HL / LH Counter System
- Each HL or LH increases a counter.
- A new HH or LL **resets** the corresponding counter to zero.
> This helps visualize how many consecutive HL or LH structures have occurred — useful for measuring trend momentum.
## 🎯 Use Cases
- Trend following and confirmation
- Early trend reversal detection
- Building structure-based trading strategies
- Understanding price behavior and market intent
---
> **Note:** This indicator does not provide financial advice. It is designed to support technical analysis with clear, structure-based visual signals.
This indicator dynamically analyzes price action to detect key market structure shifts and trend strength using four essential formations:
## 🔍 Detected Structures
- **Higher High (HH):** A candle forming a new high above recent peaks
- **Lower Low (LL):** A candle forming a new low below recent bottoms
- **Higher Low (HL):** A higher dip, indicating potential trend continuation
- **Lower High (LH):** A lower peak, signaling potential weakness
## 🧠 Structure Protection Logic
After a HH or LL is formed, if price does not breach that level within a user-defined number of candles, the level is considered **"protected."**
This provides insight into trend strength and market reaction.
## 🔢 HL / LH Counter System
- Each HL or LH increases a counter.
- A new HH or LL **resets** the corresponding counter to zero.
> This helps visualize how many consecutive HL or LH structures have occurred — useful for measuring trend momentum.
## 🎯 Use Cases
- Trend following and confirmation
- Early trend reversal detection
- Building structure-based trading strategies
- Understanding price behavior and market intent
---
> **Note:** This indicator does not provide financial advice. It is designed to support technical analysis with clear, structure-based visual signals.
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.
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.
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.