OPEN-SOURCE SCRIPT
Güncellendi Order Blocks with Volume [Quantum Algo]

Order Blocks with Volume [Quantum Algo]
OVERVIEW
This indicator finds order blocks — the candles where a directional move originated before price broke market structure — and measures the buy and sell volume that traded inside each one. Every zone is drawn as a box that extends forward until price returns to it, and each active zone is labelled with its total volume and its buy/sell split, so you can tell at a glance which blocks were built on heavy participation and which were not.
It is built entirely from price and volume on the chart you apply it to. There is no repainting of confirmed zones: detection runs only on closed bars.
HOW DETECTION WORKS
1. Market structure. Confirmed swing highs and swing lows are located using a pivot of configurable length (Swing Length). A larger value isolates more significant structure and produces fewer, larger zones.
2. Break of structure. When a candle closes above the most recent confirmed swing high (bullish) or below the most recent confirmed swing low (bearish), the indicator treats it as a break of structure and looks for the order block that produced the move.
3. The order block candle. Starting from the breakout, the script steps back over the impulse candles and marks the last opposite-close candle before the move began — the last down-close candle for a bullish block, the last up-close candle for a bearish block. This is the origin of the displacement and the level price often revisits.
4. Zone range. The block is drawn from that candle using either its full high-to-low range (Wick) or its open-to-close body (Body).
VOLUME ENGINE
For each order block candle the indicator estimates how much of the traded volume was buying versus selling, using where the candle closed within its own range:
- Buy volume is weighted by how close the candle closed to its high.
- Sell volume is weighted by how close it closed to its low.
This split is shown two ways:
- Buy / Sell volume bars: two horizontal bars anchored at the left of the zone — buy on the top half, sell on the bottom half — with lengths proportional to each side. The Volume Bar Length setting controls how long they can extend (they are automatically kept inside the zone).
- Volume label: written inside the zone on the right edge, showing the total volume of the block and the buy% / sell% balance.
Volume strength is the block's volume divided by the average volume over a configurable baseline (Volume Baseline Length). It is used by the optional filter below to keep only the heaviest blocks.
ZONE LIFECYCLE
- Active. A live zone extends to the current bar and shows its volume bars and label.
- Mitigation. When price first trades back into a zone, the 50% line marks the equilibrium and an alert can fire.
- Invalidation. A zone is invalidated when price moves through its far edge. The source can be a wick touch or a candle close (Invalidation Source).
- Breaker. If "Flip Broken Zones to Breaker Blocks" is on, an invalidated zone is kept and re-coloured as a breaker, since broken support can act as resistance and vice versa.
- Historic. If "Keep Invalidated Zones (Historic)" is on, finished zones are frozen at the bar they died, re-coloured neutral, and their volume bars and text are removed to keep the chart clean.
- If neither option is on, invalidated zones are removed.
To avoid clutter the indicator will not stack a new zone on top of an existing active zone in the same area, limits the number of active zones per side, and automatically drops any zone older than the drawing range.
ON-CHART ELEMENTS
- Coloured boxes: bullish and bearish order blocks (and a neutral colour for breaker/historic).
- Two inner bars per active zone: buy (top) and sell (bottom) volume.
- A dotted line through the middle of active zones: the 50% mitigation / equilibrium level.
- Text inside active zones: total volume and buy% / sell%.
SETTINGS
Structure & Detection
- Swing Length — pivot length used to define structure. Higher = larger, more significant zones.
- Impulse Lookback (bars) — how far back to search for the origin candle after a break of structure.
- Zone Range — Wick (full range) or Body (open-to-close).
- Max Active Zones / Side — cap on simultaneously active zones per direction.
Invalidation
- Invalidation Source — Wick (a high/low piercing the zone) or Close (a candle closing beyond it).
- Flip Broken Zones to Breaker Blocks — keep and re-colour broken zones as breakers.
- Keep Invalidated Zones (Historic) — freeze finished zones instead of deleting them.
Volume Engine
- Show Volume Label — write volume and buy/sell% inside active zones.
- Show Buy / Sell Volume Bars — draw the proportional buy/sell bars.
- Volume Baseline Length — averaging length used to rate volume strength.
- Volume Bar Length (bars) — maximum length of the buy/sell bars.
Filters
- Only Show High-Volume Zones — hide blocks below the strength threshold.
- Min Volume Strength (x avg) — threshold as a multiple of average volume.
- Filter Oversized Zones — skip blocks taller than the ATR limit.
- Max Zone Height (ATR x) — the height limit, in multiples of ATR.
Style
- Bullish Zone, Bearish Zone, Buy Volume, Sell Volume, Breaker / Historic, Text — colours.
- Zone Extension (bars) — how far active zones project past the current bar.
- Show 50% Mitigation Line — toggle the equilibrium line.
ALERTS
Alerts are raised through the alert() function for two events: an order block being tapped (mitigation) and an order block being broken (breaker formed). To use them, create an alert on the indicator and choose the "Any alert() function call" condition.
HOW TO USE
Order blocks mark areas where significant orders were likely placed. Traders commonly watch for price to return to an un-mitigated block and react there, and use the buy/sell volume split and strength to judge how meaningful a block is — a block built on high, one-sided volume is generally treated as more significant than a thin one. Combine the zones with your own confirmation and risk management; this tool highlights levels, it does not generate buy or sell signals.
DISCLAIMER
Nothing here is financial advice or a guarantee of any outcome. Past behaviour of price around order blocks does not predict future results. Always do your own research and manage risk.
OVERVIEW
This indicator finds order blocks — the candles where a directional move originated before price broke market structure — and measures the buy and sell volume that traded inside each one. Every zone is drawn as a box that extends forward until price returns to it, and each active zone is labelled with its total volume and its buy/sell split, so you can tell at a glance which blocks were built on heavy participation and which were not.
It is built entirely from price and volume on the chart you apply it to. There is no repainting of confirmed zones: detection runs only on closed bars.
HOW DETECTION WORKS
1. Market structure. Confirmed swing highs and swing lows are located using a pivot of configurable length (Swing Length). A larger value isolates more significant structure and produces fewer, larger zones.
2. Break of structure. When a candle closes above the most recent confirmed swing high (bullish) or below the most recent confirmed swing low (bearish), the indicator treats it as a break of structure and looks for the order block that produced the move.
3. The order block candle. Starting from the breakout, the script steps back over the impulse candles and marks the last opposite-close candle before the move began — the last down-close candle for a bullish block, the last up-close candle for a bearish block. This is the origin of the displacement and the level price often revisits.
4. Zone range. The block is drawn from that candle using either its full high-to-low range (Wick) or its open-to-close body (Body).
VOLUME ENGINE
For each order block candle the indicator estimates how much of the traded volume was buying versus selling, using where the candle closed within its own range:
- Buy volume is weighted by how close the candle closed to its high.
- Sell volume is weighted by how close it closed to its low.
This split is shown two ways:
- Buy / Sell volume bars: two horizontal bars anchored at the left of the zone — buy on the top half, sell on the bottom half — with lengths proportional to each side. The Volume Bar Length setting controls how long they can extend (they are automatically kept inside the zone).
- Volume label: written inside the zone on the right edge, showing the total volume of the block and the buy% / sell% balance.
Volume strength is the block's volume divided by the average volume over a configurable baseline (Volume Baseline Length). It is used by the optional filter below to keep only the heaviest blocks.
ZONE LIFECYCLE
- Active. A live zone extends to the current bar and shows its volume bars and label.
- Mitigation. When price first trades back into a zone, the 50% line marks the equilibrium and an alert can fire.
- Invalidation. A zone is invalidated when price moves through its far edge. The source can be a wick touch or a candle close (Invalidation Source).
- Breaker. If "Flip Broken Zones to Breaker Blocks" is on, an invalidated zone is kept and re-coloured as a breaker, since broken support can act as resistance and vice versa.
- Historic. If "Keep Invalidated Zones (Historic)" is on, finished zones are frozen at the bar they died, re-coloured neutral, and their volume bars and text are removed to keep the chart clean.
- If neither option is on, invalidated zones are removed.
To avoid clutter the indicator will not stack a new zone on top of an existing active zone in the same area, limits the number of active zones per side, and automatically drops any zone older than the drawing range.
ON-CHART ELEMENTS
- Coloured boxes: bullish and bearish order blocks (and a neutral colour for breaker/historic).
- Two inner bars per active zone: buy (top) and sell (bottom) volume.
- A dotted line through the middle of active zones: the 50% mitigation / equilibrium level.
- Text inside active zones: total volume and buy% / sell%.
SETTINGS
Structure & Detection
- Swing Length — pivot length used to define structure. Higher = larger, more significant zones.
- Impulse Lookback (bars) — how far back to search for the origin candle after a break of structure.
- Zone Range — Wick (full range) or Body (open-to-close).
- Max Active Zones / Side — cap on simultaneously active zones per direction.
Invalidation
- Invalidation Source — Wick (a high/low piercing the zone) or Close (a candle closing beyond it).
- Flip Broken Zones to Breaker Blocks — keep and re-colour broken zones as breakers.
- Keep Invalidated Zones (Historic) — freeze finished zones instead of deleting them.
Volume Engine
- Show Volume Label — write volume and buy/sell% inside active zones.
- Show Buy / Sell Volume Bars — draw the proportional buy/sell bars.
- Volume Baseline Length — averaging length used to rate volume strength.
- Volume Bar Length (bars) — maximum length of the buy/sell bars.
Filters
- Only Show High-Volume Zones — hide blocks below the strength threshold.
- Min Volume Strength (x avg) — threshold as a multiple of average volume.
- Filter Oversized Zones — skip blocks taller than the ATR limit.
- Max Zone Height (ATR x) — the height limit, in multiples of ATR.
Style
- Bullish Zone, Bearish Zone, Buy Volume, Sell Volume, Breaker / Historic, Text — colours.
- Zone Extension (bars) — how far active zones project past the current bar.
- Show 50% Mitigation Line — toggle the equilibrium line.
ALERTS
Alerts are raised through the alert() function for two events: an order block being tapped (mitigation) and an order block being broken (breaker formed). To use them, create an alert on the indicator and choose the "Any alert() function call" condition.
HOW TO USE
Order blocks mark areas where significant orders were likely placed. Traders commonly watch for price to return to an un-mitigated block and react there, and use the buy/sell volume split and strength to judge how meaningful a block is — a block built on high, one-sided volume is generally treated as more significant than a thin one. Combine the zones with your own confirmation and risk management; this tool highlights levels, it does not generate buy or sell signals.
DISCLAIMER
Nothing here is financial advice or a guarantee of any outcome. Past behaviour of price around order blocks does not predict future results. Always do your own research and manage risk.
Sürüm Notları
On-chart symbol + timeframe tag (House Rules: chart clarity)Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
The institutional Edge: Indicators, Strategies & a Free Academy. quantum-algo.com
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
The institutional Edge: Indicators, Strategies & a Free Academy. quantum-algo.com
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.