OPEN-SOURCE SCRIPT

Order Block Zones | AlphaScript

398
Order Block Zones automatically detects and tracks institutional order blocks the candles where significant buying or selling originated and manages each zone through its full lifecycle from formation to mitigation.

💡What an order block is
An order block is the last candle before a strong directional move: the point where institutional orders were placed before price left the area. Traders watch these zones because price often returns to them, using the untraded liquidity as support (bullish OB) or resistance (bearish OB). This tool identifies those zones systematically instead of by eye.

🔍How detection works
Zones are anchored to confirmed swing pivots. A bullish order block is drawn from a down-candle at a confirmed swing low; a bearish order block from an up-candle at a confirmed swing high. Pivots are confirmed using a symmetrical lookback (default 10 bars each side), so a zone only appears after the pivot is fully validated — the detection does not repaint. You can define the zone boundaries two ways: Full Candle (high to low, the complete range) or Body Only (open to close, a tighter zone focused on the candle body).

⚙️Filtering for quality
Not every pivot candle is worth marking. Two optional filters keep the chart focused on significant zones:

ATR Size Filter — the candle's range must exceed a multiple of ATR, so only meaningfully large origin candles qualify.
Volume Filter — the candle's volume must exceed a multiple of its 20-period average, favoring zones formed on genuine participation.
A configurable cap limits how many active zones are tracked per side, keeping the most recent and relevant ones.

🎯Mitigation tracking — the core of the tool
A zone stays active until price invalidates it. You choose how invalidation is measured:

Close mode — the zone is mitigated when a candle closes through it (stricter, fewer false invalidations).
Wick mode — the zone is mitigated on any wick penetration (more sensitive).
When a zone is mitigated you can either remove it (Delete) or leave a dimmed marker where it was (Keep Faded), so you can see where past zones were tested.

📈How to use it
Treat active bullish zones as potential demand (support) and active bearish zones as potential supply (resistance). Watch for price returning to an unmitigated zone as a possible reaction area, and use the mitigation state to know when a level has genuinely failed rather than held. The zone's midline gives a reference level within the block. Combine it with your own structure read and higher-timeframe bias — the tool marks the zones, you make the decisions.

🎨Customization
Zone fill and border opacity, border width, extension length, midline style and width, label size, side, and text, and full color control — so the zones fit your chart rather than forcing a fixed look.

🔔Alerts
Bullish/bearish order block formed, and bullish/bearish order block mitigated.

📌Notes
Zones are drawn from confirmed pivots and evaluated on closed bars only — signals do not repaint intrabar. Detection quality depends on the pivot length and filters; adjust them to your instrument and timeframe. Order blocks mark areas of interest, not guaranteed reversals — always combine with your own analysis and risk management.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.