OPEN-SOURCE SCRIPT

Order Blocks Zones with Signals

329
█ OVERVIEW
“Order Blocks Zones with Signals” is a technical analysis tool that automatically identifies Order Blocks (OB) and optionally Fair Value Gaps (FVG) on the chart.
The script visualizes these zones as colored rectangles, offering full customization of style, transparency, and signal display.
It also generates entry and exit signals (Break & Exit) that can serve as confirmations in strategies based on price action and market structure.
Thanks to flexible candle size filters and rich visual options, the indicator maintains chart clarity and readability.

█ CONCEPTS
Order Blocks (OB) are key zones on the chart where significant price movements previously occurred — areas where large market participants (institutions, so-called smart money) initiated or closed positions.
An OB is the last candle that followed the prior trend before the market reversed (e.g., for a Bullish OB: the last bearish candle before a pivot low and a strong upward impulse).
The script detects these levels using local price pivots, analyzing candle direction to filter out less significant movements.

FVG (Fair Value Gaps) represent areas of imbalance between buyers and sellers — price gaps formed by a sharp impulse where full trading did not occur due to one-sided order dominance (e.g., excess buy or sell orders).

Why combine OB and FVG in one indicator?
Combining OB and FVG analysis is essential because these phenomena often occur sequentially in the institutional market cycle:

1. Order Block — institutions enter the market in the OB zone, absorbing orders and building positions.
2. Strong impulse — after smart money entry, a rapid price move creates an FVG (imbalance gap).
3. Retest — price naturally returns to these zones (OB or FVG), drawn by unfilled orders and the search for equilibrium.

Such areas strongly attract price, as they represent not only historical institutional levels but also open “holes” in the order book. Retests of OB and FVG are ideal entry opportunities with high reaction probability (rebound or breakout). The indicator combines these two interconnected elements, enabling comprehensive market structure analysis in a single tool.

Order Blocks are labeled as:
Bullish OB – demand zones, often accumulation areas before an upmove.
Bearish OB – supply zones, signaling potential impulse end or correction start.

█ FEATURES
Order Block Detection (OB Detection):
- Automatic identification of demand and supply zones based on pivots.
- OB is the last candle aligned with the prior trend, just before the market reversal — precisely identified through candle sequence analysis around the pivot.
- OB zones appear with a delay equal to Pivot Length (default 10 bars).
- Break signals trigger when a candle’s body (close) fully pierces the zone, causing the zone to disappear immediately (e.g., close < low of Bullish OB → Break Down and zone deletion).
- Minimum size filtering via OB Size Multiplier.
- Option to create OB without wicks (Include Wicks in OB): when disabled, OB zones are based solely on candle bodies (open/close), ignoring wicks (high/low).

Fair Value Gap Detection (FVG Detection):
- Optional, with enable/disable capability.
- FVG are detected without delay — immediately upon gap occurrence.
- Size filtering via Candle Size Period and FVG Size Multiplier.

Customizable Styling:
- Separate colors and border styles (Solid / Dashed / Dotted) for each zone type.
- Adjustable transparency and border thickness.
- Unified color for box, border, and signal of the same type.

Breakout and Exit Signals:
- Break Up – triggered when a candle’s close breaks above a Bearish OB, causing the zone to disappear.
- Break Down – triggered when a candle’s close breaks below a Bullish OB, causing the zone to disappear.
- Exit Up / Exit Down – temporary exit from the zone without full breakout (price leaves the zone but doesn’t close beyond it). Signal type selection: Break, Exit, or Both.
- Alerts: built-in alerts for all signal types — triggered automatically on candle close confirming breakout or exit from OB.

█ HOW TO USE
Adding to chart: import the code into Pine Editor and run the script on TradingView.

Settings configuration:
- Pivot Length: controls swing detection sensitivity and OB display delay (default 10).
- Include Wicks in OB: enabled (default) – OB includes wicks; disabled – OB uses bodies only.
- Size Filter: adjust Candle Size Period and OB/FVG Size Multiplier to filter out small zones.
- Colors & Styles: set colors, styles, and transparency for each zone type.
- Signal Type: choose which signals to display (Break, Exit, or Both).

Signal interpretation:
- OB Break Up: price closes above Bearish OB → zone disappears → potential bullish continuation.
- OB Break Down: price closes below Bullish OB → zone disappears → potential bearish continuation.
- Exit Signals: price leaves the zone temporarily without breakout — often signals impending reversal or pullback.

Tips:
- Use OB signals alongside other indicators like RSI, MACD, SMI, or trend filters.
- Order Blocks from higher timeframes (e.g., 4H, 1D) carry greater significance and reaction strength.
- Remember: FVG are detected immediately, OB with delay — a complementary approach!

█ APPLICATIONS
- Smart Money Concepts (SMC): use OB zones as dynamic support and resistance levels. In an uptrend, look for buy opportunities in bullish OBs, which price often retests before further gains. Combining with RSI, MACD, or Fibonacci levels enhances zone significance, confirming institutional demand.
- Breakout Trading: trade based on OB breakout signals. A buy signal after breaking a bearish OB may indicate a strong upward impulse, especially if supported by rising MACD or RSI above 50. Similarly for sell signals after Break Down.
- Reversal Zones: Exit signals may indicate the end of a move or correction. Safest to use in alignment with higher-timeframe trend and confirmed by another indicator (e.g., RSI divergence, Fibonacci levels).
- Confluence Analysis: combine OB and FVG for deeper market structure and equilibrium insight. When an Order Block overlaps or borders an FVG, we get confluence of two institutional phenomena — OB (smart money entry) + FVG (imbalance) — making these areas particularly strong price magnets, increasing retest and reaction probability.

█ NOTES
- FVG can be fully disabled for a cleaner chart view.
- In consolidation periods, signals may appear more frequently — always confirm with additional trend filters.
- Works on all markets and timeframes (crypto, forex, indices, stocks).

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.