OPEN-SOURCE SCRIPT
Sweep OB + Breaker [HA] MTF

# Sweep OB + Breaker [HA] MTF
## Overview
This indicator detects **Order Blocks (OB)** and **Breaker Blocks (BRK)** using **Heikin-Ashi** candles across two timeframes simultaneously — your current chart timeframe (LTF) and a configurable higher timeframe (HTF, default 15m).
The logic is rooted in **SMC (Smart Money Concepts)**: it only marks a zone after a complete sequence of **Liquidity Sweep → Change of Character (CHoC) → Order Block identification**, ensuring every zone has a structural narrative behind it.
---
## Core Logic
### Step 1 — Liquidity Sweep
The indicator detects when a Heikin-Ashi wick pierces below a prior swing low (or above a prior swing high) and **closes back inside** — signaling a stop hunt rather than a genuine breakout.
### Step 2 — Change of Character (CHoC)
After a sweep, the script watches for the HA close to break the **opposite swing level**, confirming a structural reversal. This is the CHoC — the market has changed hands.
### Step 3 — Order Block
Once the CHoC is confirmed, the script looks back from the CHoC candle and marks the **last opposing-color HA candle** before the reversal. This candle is the Order Block — the last footprint of institutional activity before the move.
### Step 4 — Breaker Block
When price fully **closes through an OB**, that zone doesn't disappear — it flips into a **Breaker Block** with inverted polarity (a former support becomes resistance, and vice versa), displayed with a dashed border.
---
## Zone States
Each zone is tracked in real time:
| State | Description |
|---|---|
| **Naked** | Zone untouched since creation |
| **Mitigated** | Price has entered the zone |
| **Liquidated → Breaker** | Price closed fully through the zone — converts to Breaker |
---
## Multi-Timeframe Confluence
The HTF engine runs the same Sweep → CHoC → OB/BRK logic independently on your chosen higher timeframe. This gives you two layers of information simultaneously:
- **HTF direction** — a real-time label (▲ Bullish / ▼ Bearish / — Neutral) shows the current HTF trend based on the last HTF CHoC
- **HTF zones** — displayed with a thicker border and labeled "HTF OB ▲/▼" or "HTF BRK ▲/▼" so they're immediately distinguishable from LTF zones
- **Confluence highlight** — when price is inside an HTF zone AND the HTF direction aligns with the LTF signal, the bar background turns green (long) or red (short), giving you a clear visual cue that all timeframes agree
---
## How to Use
**Scalping (e.g. 1m chart):** set HTF to 5m or 15m. Look for LTF CHoC labels that appear while price is inside an HTF zone and the HTF label reads Bullish/Bearish.
**Intraday (e.g. 5m–15m chart):** set HTF to 1h or 4h. Use HTF zones as macro support/resistance and enter on LTF OB retests.
**Swing (e.g. 1h–4h chart):** set HTF to Daily. Only trade LTF setups that occur inside Daily OB or BRK zones.
The ideal entry sequence:
1. HTF CHoC confirms direction
2. Price pulls back into an HTF OB or BRK zone
3. On the LTF, a new Sweep → CHoC fires in the same direction
4. Bar background highlights — this is your entry window
---
## Inputs
| Parameter | Description |
|---|---|
| LTF Swing Lookback | Number of candles left/right to confirm a swing pivot on the chart TF |
| LTF OB Search Bars | How many bars back to look for the last opposing HA candle |
| Higher Timeframe | The HTF to run the second analysis on (default: 15m) |
| HTF Swing Lookback | Same as LTF but for the HTF engine |
| Show LTF / HTF Zones | Toggle visibility of each layer independently |
| LTF / HTF Colors | Fully customizable colors for all 4 zone types on each timeframe |
---
## Alerts
4 alert conditions are available:
- **LTF Bullish CHoC** — a bullish CHoC was confirmed on the chart timeframe
- **LTF Bearish CHoC** — a bearish CHoC was confirmed on the chart timeframe
- **Long Confluence** — HTF is bullish, price is in an HTF bull zone, and LTF aligned
- **Short Confluence** — HTF is bearish, price is in an HTF bear zone, and LTF aligned
The **Long/Short Confluence** alerts are the highest-quality signals — set these with "Once per bar close" to avoid noise.
---
## Notes
- All structure detection runs on **Heikin-Ashi values** fetched via `request.security` for accuracy regardless of your chart candle type. Entry/exit decisions are left to the trader and use real price levels.
- HTF data uses `lookahead=barmerge.lookahead_off` to prevent repainting.
- Only the **most recent** OB and Breaker per direction are kept active at any time, keeping the chart clean.
- Works on any instrument and any timeframe. Recommended to keep LTF Swing Lookback between 3–10 for scalping and 5–15 for intraday.
## Overview
This indicator detects **Order Blocks (OB)** and **Breaker Blocks (BRK)** using **Heikin-Ashi** candles across two timeframes simultaneously — your current chart timeframe (LTF) and a configurable higher timeframe (HTF, default 15m).
The logic is rooted in **SMC (Smart Money Concepts)**: it only marks a zone after a complete sequence of **Liquidity Sweep → Change of Character (CHoC) → Order Block identification**, ensuring every zone has a structural narrative behind it.
---
## Core Logic
### Step 1 — Liquidity Sweep
The indicator detects when a Heikin-Ashi wick pierces below a prior swing low (or above a prior swing high) and **closes back inside** — signaling a stop hunt rather than a genuine breakout.
### Step 2 — Change of Character (CHoC)
After a sweep, the script watches for the HA close to break the **opposite swing level**, confirming a structural reversal. This is the CHoC — the market has changed hands.
### Step 3 — Order Block
Once the CHoC is confirmed, the script looks back from the CHoC candle and marks the **last opposing-color HA candle** before the reversal. This candle is the Order Block — the last footprint of institutional activity before the move.
### Step 4 — Breaker Block
When price fully **closes through an OB**, that zone doesn't disappear — it flips into a **Breaker Block** with inverted polarity (a former support becomes resistance, and vice versa), displayed with a dashed border.
---
## Zone States
Each zone is tracked in real time:
| State | Description |
|---|---|
| **Naked** | Zone untouched since creation |
| **Mitigated** | Price has entered the zone |
| **Liquidated → Breaker** | Price closed fully through the zone — converts to Breaker |
---
## Multi-Timeframe Confluence
The HTF engine runs the same Sweep → CHoC → OB/BRK logic independently on your chosen higher timeframe. This gives you two layers of information simultaneously:
- **HTF direction** — a real-time label (▲ Bullish / ▼ Bearish / — Neutral) shows the current HTF trend based on the last HTF CHoC
- **HTF zones** — displayed with a thicker border and labeled "HTF OB ▲/▼" or "HTF BRK ▲/▼" so they're immediately distinguishable from LTF zones
- **Confluence highlight** — when price is inside an HTF zone AND the HTF direction aligns with the LTF signal, the bar background turns green (long) or red (short), giving you a clear visual cue that all timeframes agree
---
## How to Use
**Scalping (e.g. 1m chart):** set HTF to 5m or 15m. Look for LTF CHoC labels that appear while price is inside an HTF zone and the HTF label reads Bullish/Bearish.
**Intraday (e.g. 5m–15m chart):** set HTF to 1h or 4h. Use HTF zones as macro support/resistance and enter on LTF OB retests.
**Swing (e.g. 1h–4h chart):** set HTF to Daily. Only trade LTF setups that occur inside Daily OB or BRK zones.
The ideal entry sequence:
1. HTF CHoC confirms direction
2. Price pulls back into an HTF OB or BRK zone
3. On the LTF, a new Sweep → CHoC fires in the same direction
4. Bar background highlights — this is your entry window
---
## Inputs
| Parameter | Description |
|---|---|
| LTF Swing Lookback | Number of candles left/right to confirm a swing pivot on the chart TF |
| LTF OB Search Bars | How many bars back to look for the last opposing HA candle |
| Higher Timeframe | The HTF to run the second analysis on (default: 15m) |
| HTF Swing Lookback | Same as LTF but for the HTF engine |
| Show LTF / HTF Zones | Toggle visibility of each layer independently |
| LTF / HTF Colors | Fully customizable colors for all 4 zone types on each timeframe |
---
## Alerts
4 alert conditions are available:
- **LTF Bullish CHoC** — a bullish CHoC was confirmed on the chart timeframe
- **LTF Bearish CHoC** — a bearish CHoC was confirmed on the chart timeframe
- **Long Confluence** — HTF is bullish, price is in an HTF bull zone, and LTF aligned
- **Short Confluence** — HTF is bearish, price is in an HTF bear zone, and LTF aligned
The **Long/Short Confluence** alerts are the highest-quality signals — set these with "Once per bar close" to avoid noise.
---
## Notes
- All structure detection runs on **Heikin-Ashi values** fetched via `request.security` for accuracy regardless of your chart candle type. Entry/exit decisions are left to the trader and use real price levels.
- HTF data uses `lookahead=barmerge.lookahead_off` to prevent repainting.
- Only the **most recent** OB and Breaker per direction are kept active at any time, keeping the chart clean.
- Works on any instrument and any timeframe. Recommended to keep LTF Swing Lookback between 3–10 for scalping and 5–15 for intraday.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.