Market Structure- ZigZag, Break of Structure & Order Blocks

This script is an all-in-one market structure tool designed for traders who follow price action, Smart Money Concepts (SMC), or institutional order flow. It combines Order Block detection, Break of Structure (BOS), Internal Structure Shifts (CHoCH), and a ZigZag swing framework to provide a clear and actionable view of market behavior.
Key Features:
Order Blocks (OB):
-Detects Bullish (Green) and Bearish (Red) order blocks upon valid market structure shifts.
-Optional deletion of mitigated (touched) blocks to keep charts clean.
-Customizable block duration, fill color, and border color.
Break of Structure (BOS):
-Marks BOS with horizontal dotted lines when price breaks previous swing highs/lows.
-Confirms new trends and structural shifts.
Internal Structure Shifts (CHoCH-like):
-Detects early internal changes in direction before BOS.
-User-selectable logic: based on candle Open or High/Low.
-Plotted as small black triangle markers.
ZigZag Swings:
-Connects confirmed internal shifts with black zigzag lines.
-Visually simplifies trend structure and major swing points.
-Tracks last swing highs/lows for BOS validation.
Alerts:
-Bullish/Bearish Engulfments (OB signals)
-Internal Structure Shifts
-Bullish/Bearish Break of Structure
-OB Mitigation Events
Inputs & Settings:
-Show/Hide Bullish or Bearish Order Blocks
-Calculate internal shifts by: Open or High/Low
-Set order block fill and border colors
-Enable or disable automatic deletion of mitigated blocks
-Set duration for order block display
This tool is designed to support price action trading by visually mapping key structural changes and zones of interest directly on your chart. It is not intended to function as a standalone trading strategy, but rather as a supplementary tool to inform your own analysis and discretion.
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.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Penafian
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.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.