OPEN-SOURCE SCRIPT

Inversion Order Blocks [iOB] (Zeiierman)

6 643
Overview
Inversion Order Blocks [iOB] (Zeiierman) identifies when traditional Order Blocks fail and transition into inversion zones where the opposing side of the market may gain control.

A regular Order Block represents the final opposing candle before a strong displacement move breaks market structure. These areas are commonly monitored as potential support or resistance because they mark the origin of aggressive buying or selling pressure.

However, not every Order Block remains valid.

Some Order Blocks are broken as price closes completely through them. Rather than immediately discarding these failed zones, the indicator stores them inside an internal memory system and watches for a later opposing Order Block to form in the same price region.

When an Order Block fails, the indicator remembers it. If an opposite Order Block forms soon after in the same price area, either overlapping it or sitting very close to it, that area becomes an Inversion Order Block.

This creates a more selective framework that focuses on failed Order Blocks followed by confirmation from the opposite side of the market.
syot kilat
Order Block Detection
The indicator continuously scans the price for displacement candles that close through recent market structure.

A Bullish Order Block forms when:

• A bullish displacement candle closes above the previous structure high.
• The candle range exceeds the minimum ATR requirement.
• The candle body occupies the required percentage of its total range.
• The nearest bearish candle before the displacement becomes the bullish Order Block.
syot kilat

A Bearish Order Block forms when:

• A bearish displacement candle closes below the previous structure low.
• The candle range exceeds the minimum ATR requirement.
• The candle body occupies the required percentage of its total range.
• The nearest bullish candle before the displacement becomes the bearish Order Block.
syot kilat
Inversion Order Block Detection
Once an Order Block is created, it enters the internal memory system. If price later closes through the far side of the Order Block, the zone is considered broken.

A broken Order Block is not immediately forgotten. It remains eligible to pair with a later opposing Order Block for the duration of the Pairing Window.

Unlike strict inversion models, the two Order Blocks do not need to overlap perfectly. They may also form within a small ATR-adjusted proximity controlled by the Maximum Pairing Proximity setting.

Bullish iOB

• A bearish Order Block is broken.
• A bullish Order Block forms within the Pairing Window.
• The two zones overlap or form within the allowed proximity.
• The resulting area becomes a bullish Inversion Order Block.
syot kilat
Bearish iOB

• A bullish Order Block is broken.
• A bearish Order Block forms within the Pairing Window.
• The two zones overlap or form within the allowed proximity.
• The resulting area becomes a bearish Inversion Order Block.
syot kilat
How It Works
Order Block Detection
The script searches for strong displacement candles that close beyond recent market structure.

Each displacement is filtered using:

• ATR-based candle range.
• Minimum candle body ratio.
• Minimum Order Block size.

The nearest opposing candle before the displacement becomes the Order Block.

Memory & iOB Formation
Every valid Order Block is stored internally.

A bullish OB is considered broken when price closes below it, while a bearish OB is broken when price closes above it.

If a later opposing OB forms within the Pairing Window, the script checks whether the two zones overlap or sit within the Maximum Pairing Proximity.
Pine Script®

When they overlap, the shared price area becomes the iOB. When they are only nearby, the failed original OB becomes the inversion zone.

Zone Management
Each zone can transition through several states:

• Active
• Tested
• Mitigated
• Frozen
• Removed

Mitigation may use wick touches or candle closes and can occur at the 50% level or after a full fill. Mitigated zones can either be deleted or retained as historical references.

Dynamic Zone Merging
Nearby compatible zones may be combined visually to reduce clutter.

• Bullish OBs merge with bullish OBs.
• Bearish OBs merge with bearish OBs.
• Bullish and bearish iOBs may merge into one neutral Merged iOB.
• Live and retained mitigated zones remain separate.

Retained zones only merge when their historical active periods overlap.

Distance Filtering
Zones beyond the selected ATR distance from the current price are hidden from the chart.

Hidden zones remain internally active and continue updating their memory, mitigation, and alert states.

How to Use

Bullish iOB Retest
After a bearish Order Block fails and a later bullish Order Block confirms the inversion, the resulting bullish iOB may act as support.

Rather than entering during the initial displacement, traders can wait for price to retrace into the bullish iOB.

A bullish reaction from the zone may indicate that buyers are defending the former resistance area.
syot kilat
Bearish iOB Retest
After a bullish Order Block fails and a later bearish Order Block confirms the inversion, the resulting bearish iOB may act as resistance.

Traders can wait for price to retrace into the bearish iOB and observe whether selling pressure returns.

A bearish reaction may indicate that sellers are defending the former support area.
syot kilat
Settings
  • Structure Lookback: Number of completed bars used to determine the structure high or low that a displacement candle must close through.
  • Order Block Search: Number of previous candles searched to locate the nearest opposing candle before the displacement.
  • Minimum Displacement Range: Minimum candle range measured as a multiple of ATR before a displacement is accepted.
  • Minimum Displacement Body: Minimum percentage of the displacement candle that must be occupied by its body.
  • Order Block Source: Select whether Order Blocks use the complete candle range or only the candle body.
  • Minimum Order Block Size: Minimum ATR-adjusted size required before an Order Block is accepted.
  • Pairing Window: Number of bars a broken Order Block remains eligible to pair with a later opposing Order Block.
  • Maximum Memory Age: Maximum number of bars an Order Block may remain inside the internal memory system.
  • Maximum Pairing Proximity: Maximum ATR-adjusted distance allowed between a failed Order Block and a later opposing Order Block. A value of zero requires direct overlap.
  • Delete Mitigated Zones: Removes mitigated zones or freezes them as historical references.
  • Mitigation Level: Select whether mitigation occurs at the 50% equilibrium level or after a complete fill.
  • Mitigation Source: Uses wick penetration or candle closes to confirm mitigation.
  • Merge Retained Mitigated Zones: Visually combines compatible historical zones that overlap in both price and active time.
  • Mitigated Zone Transparency: Controls how transparent retained historical zones appear.
  • Show Mitigated EQ Lines: Displays or hides equilibrium lines inside retained mitigated zones.
  • Filter Distant Zones: Hides Order Blocks and iOBs that are far away from the current price.
  • Maximum Distance From Price: Maximum ATR distance allowed before a zone becomes hidden.
  • Merge Nearby Zones: Visually combines compatible live zones and retained mitigated zones.
  • Maximum Merge Distance: Controls how close compatible zones must be before they merge visually.
  • Show iOBs: Displays bullish, bearish, and merged Inversion Order Blocks.
  • Show Regular OBs: Displays regular bullish and bearish Order Blocks. Detection and memory remain active when regular OBs are hidden.
  • Show EQ Line: Displays the equilibrium midpoint of each visible zone.
  • Fade With Age: Gradually increases zone transparency as the zone becomes older.

-----------------
Disclaimer

The content provided in my scripts, indicators, ideas, algorithms, and systems is for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to buy or sell any financial instruments. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.

All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.