OPEN-SOURCE SCRIPT

Order Block Mitigation Profiler [forexobroker]

734
Order Block Mitigation Profiler [forexobroker] locates institutional order blocks and tracks each one through a full lifecycle: OPEN (untouched), TOUCHED (price traded back in), and MITIGATED (price closed through). The unique angle is the dual-layer engine: instead of only firing the rare classic one-shot retest, a fresh block arms a persistent directional bias and entries are timed by an EMA reclaim inside that bias, keeping signal cadence usable on live charts.

🔶 ALGORITHM

1. Confirm swing structure with symmetric pivots (ta.pivothigh / ta.pivotlow), tracking the most recent confirmed swing high and low.
2. Detect a Break of Structure (BOS): close crosses the last confirmed swing pivot (close > lastPH while prior close was at or below it, mirrored for bearish).
3. Walk back up to OB Search Lookback bars from the BOS to find the last opposing-direction candle; that candle's high/low defines the order block.
4. Validate displacement: the impulse leg from the block must span at least Min Impulse x ATR, filtering out non-institutional moves.
5. Lifecycle state machine per block: state 1 (OPEN), 2 (TOUCHED on first retest), 3 (MITIGATED when the mitigation reference closes/wicks through).
6. Persistent bias: a freshly formed OB sets bias +1 / -1; the bias clears only when that block is mitigated.
7. Entry timing: within an active bias, an EMA reclaim (ta.crossover / ta.crossunder of close vs the Entry Reclaim EMA) fires the trade. Retest-Only Mode swaps this for the strict first-retest event.

🔶 SIGNAL LOGIC

- Buy: bullish bias active (fresh bull OB, not yet mitigated) and close crosses over the Entry Reclaim EMA (or, in Retest-Only Mode, the first bull OB retest), in session, with position not already long, after the cooldown window has elapsed, and only on barstate.isconfirmed; a position-lock state flips to LONG to prevent stacking.
- Sell: bearish bias active (fresh bear OB, not yet mitigated) and close crosses under the Entry Reclaim EMA (or the first bear OB retest), in session, position not already short, cooldown elapsed, on barstate.isconfirmed; position-lock flips to SHORT.
Only fires when a fresh, unmitigated order block has set directional bias.

🔶 INPUTS

- Structure: pivot length for swing confirmation (default 8), OB search lookback, and ATR length.
- Impulse filter: minimum impulse measured in ATR multiples to qualify a block (default 1.0x ATR).
- Mitigation rule: mitigate on close versus wick-through toggle (default close).
- Signal Logic: Entry Reclaim EMA length (default 9) and Retest-Only Mode toggle (default off = regime + EMA reclaim).
- Cooldown: minimum bars between signals (default 5).
- Filters: optional session restriction with a session window, and one-signal-per-block lock (default on).
- Visual: OB zone boxes, dashboard, 3-layer glow, buy/sell colors, and dashboard background.

🔶 ALERTS

OBM Buy, OBM Sell, OBM Any Signal, OBM Bull BOS, OBM Bear BOS, OBM Bull OB Formed, OBM Bear OB Formed, OBM Bull Mitigated, OBM Bear Mitigated, OBM Bull Retest, OBM Bear Retest, OBM Structure Break, OBM Webhook JSON.

🔶 LIMITATIONS

- Requires warm-up: pivots only confirm after Pivot Length bars on each side, so early chart history produces no structure.
- Defaults (ATR 14, impulse 1.0x) are tuned for liquid instruments; thin or low-volatility symbols may need a lower impulse multiple.
- Retest-Only Mode is intentionally rare and can go long stretches with no signal; the default regime + EMA reclaim mode trades more frequently.
- Non-repainting by design (pivots confirmed, signals on bar close), which means the swing that anchors a block appears Pivot Length bars after it actually formed.
- Order blocks are structural zones, not guaranteed reversals; the impulse and ATR filters reduce but do not eliminate false breaks.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.