OPEN-SOURCE SCRIPT
Atualizado Market Structure- ZigZag, Break of Structure & Order Blocks

Description:
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.
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.
Notas de Lançamento
Added labels to indicate higher highs (HH), lower highs (LH), lower lows (LL), and higher lows (HL).Notas de Lançamento
New alerts added (HH, LH, LL, HL).Notas de Lançamento
New signal added: Liquidity Sweep (LS)Alerts are fixed.
Notas de Lançamento
Alerts updated for accuracyNotas de Lançamento
Market Structure Indicator – ZigZag, Break of Structure & Order BlocksCreated by: The_Forex_Steward
This script presents a complete and original market structure framework that identifies price structure in real-time using a multi-step approach. It combines order blocks, internal market shifts, swing point analysis, breaks of structure, and a zigzag visual aid to help traders identify the market’s internal and external flow on any timeframe.
🔍 What the Script Does:
1. Order Blocks (OBs)
The script detects bullish and bearish engulfing patterns and uses the engulfed candle to define an order block (OB). These zones act as potential areas of supply/demand and are visually marked on the chart. Mitigated blocks (i.e., when price invalidates the zone) can optionally be removed automatically.
2. Internal Market Shift (IMS)
When price closes beyond the level of the engulfed candle, it signals an internal shift in order flow. This marks the beginning of a potential trend change within the current timeframe.
3. Swing Highs/Lows (HH, HL, LH, LL)
Each internal shift is followed by identification of swing points, which are labeled and categorized to form a clear visual map of the market structure:
-HH – Higher High
-HL – Higher Low
-LL – Lower Low
-LH – Lower High
-LS – Liquidity Sweep (potential false break where no structure is confirmed)
4. Break of Structure (BoS)
A Break of Structure occurs when price closes beyond a previous swing high or low, confirming a shift in external market structure. These are plotted as horizontal dotted lines, highlighting major trend transitions.
5. ZigZag Lines
A dynamic zigzag is drawn between structural points to help visualize the flow of highs and lows, aiding in trend recognition and cleaner chart reading.
6. Alerts
The indicator includes customizable alerts for:
-New order blocks
-Internal shifts
-Swing point creation (HH, HL, LH, LL)
-Breaks of structure
-Mitigated order blocks
-Liquidity sweeps
📈 How to Use It in Trading:
1. Determine Market Direction:
Use the most recent Break of Structure (BoS) to define the external trend.
2. Wait for a Setup:
Once the trend is identified (bullish or bearish), wait for a corresponding HL or LH to form.
3. Enter at Mitigated OB:
Set a buy or sell limit at the relevant order block. The stop loss can be placed just beyond the OB boundary.
4. Take Profit Options:
-At the previous high/low
-After the next internal shift
-Or hold until an opposing BoS occurs
5. Automate with Alerts:
Use the built-in alerts to automate detection and notification of all major structural events.
⚙️ Originality & Purpose
Every part of this indicator was independently developed by The_Forex_Steward. It is not a mashup of preexisting scripts but a conceptually unified tool designed to reflect the logic of price action trading, from internal order flow to trend confirmation. The progression of logic—engulfments → order blocks → internal shifts → swing highs/lows → breaks of structure—represents a full-spectrum market structure approach designed for clarity and precision.
Notas de Lançamento
Update: User can choose length of order block boxesScript de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.