Order Block Detector [SMC ChartSense]# SMC ChartSense — Order Block Detector
**Order block detection with mandatory FVG (Fair Value Gap) confirmation.** Each zone marked must have a 3-bar FVG at the anchor candle — institutional displacement that left a literal gap in price. Most basic OB scripts flag every breakout candle as an order block; this script filters to only the zones that came with displacement footprint, producing a cleaner chart with fewer but more meaningful zones.
## How it works
The script tracks swing pivots at a configurable length and waits for a confirmed break — a candle that closes beyond the prior swing high or low. When a break occurs, it searches back through the recent bars to identify the deepest counter-direction candle (lowest low for a bullish OB, highest high for a bearish OB). This becomes the OB anchor.
The anchor is then validated against the FVG requirement: there must be a 3-bar gap at the anchor index (bar A high below bar C low for bullish, bar A low above bar C high for bearish). No FVG, no OB. This is the central quality filter.
Validated zones extend forward from the anchor and remain active until invalidated — either when price closes through the zone or when the wick touches the far side, depending on user preference.
## Features
- FVG validation gate at the anchor candle (3-bar gap requirement)
- Configurable swing pivot length for structural sensitivity
- User-tunable OB anchor lookback (5–100 bars)
- Wick-based or body-based zone definition
- Configurable mitigation trigger: Close-through or Wick-touch
- Auto-pruning of oldest OBs when active count exceeds limit
- Optional faded display of mitigated zones for historical study
- Built on Pine v6 with clean, maintainable architecture
## Inputs
**Structure Detection**
- *Swing Pivot Length* — Higher values produce fewer, more significant pivots. Lower values produce more frequent pivots of smaller structural significance. Default: 5.
**Quality Filters**
- *OB Anchor Lookback Bars* — How far back from a confirmed pivot break to search for the OB anchor candle. Default 30 covers most timeframes; reduce for scalping, increase for higher TFs.
- *Anchor OB to Wick (vs Body)* — Wick mode uses the full candle range. Body mode uses open/close only (tighter zones).
- *Mitigation Trigger* — Close mode invalidates when a candle closes through the zone. Wick mode invalidates on first wick touch.
**Visualization**
- Bull/Bear OB colors (customizable)
- Max OBs Per Side (caps active display, oldest auto-pruned)
- Show OB Labels (off by default — boxes alone are usually sufficient)
- Show Midline (50% level inside each OB, dotted)
- Keep Mitigated OBs Visible (faded gray boxes remain for historical reference)
## Built-in alerts
- New Bull OB formed
- New Bear OB formed
- Bull OB touched (price entered zone)
- Bear OB touched (price entered zone)
## Suggested use
Best on liquid intraday markets — major forex pairs, crypto perps, index futures, large-cap equities — at timeframes from 5m to 4h. Default settings are tuned for 15m–1h ranges; adjust Swing Pivot Length down to 3 for scalping or up to 8–10 for higher-TF trend trading.
Use this as a context tool. The zones identify where institutional displacement occurred — actual entries should incorporate your own analysis: HTF bias, structural alignment with current market regime, risk-reward planning, and confirmation from other tools.
## Part of the SMC ChartSense suite
One of several focused SMC tools. Designed to work alongside other SMC ChartSense scripts for a coherent analytical workflow across the SMC vocabulary.
## Disclaimer
This is a technical analysis tool. It does not provide investment advice or trade recommendations. The author is not a SEBI-registered Research Analyst. Use at your own risk; do your own due diligence.
Pine Script® Indikator






















