OPEN-SOURCE SCRIPT
Aggiornato Order Blocks + Order-Flow Proxies

Order Blocks + Order-Flow Proxies
This indicator combines structural analysis of order blocks with lightweight order-flow style proxies, providing a tool for chart annotation and contextual study. It is designed to help users visualize where significant structural shifts occur and how simple volume-based signals behave around those areas. The script does not guarantee profitable outcomes, nor does it issue financial advice. It is intended purely for research, learning, and discretionary use.
Conceptual Background
Order Blocks
An “order block” is a term often used to describe a zone on the chart where price left behind a significant reversal or imbalance before continuing strongly in the opposite direction. In practice, this can mean the last bullish or bearish candle before a strong breakout. Traders sometimes study these regions because they believe that unfilled resting orders may exist there, or simply because they mark important pivots in price structure. This indicator detects such moments by scanning for breaks of structure (BOS). When price pushes above or below recent swing levels with sufficient displacement, the script identifies the prior opposite candle as the potential order block.
Break of Structure
A break of structure in this context is defined when the closing price moves beyond the highest high or lowest low of a short lookback window. The script compares the magnitude of this break to an ATR-based displacement filter. This helps ensure that only meaningful moves are marked rather than small, random fluctuations.
Order-Flow Proxies
Traditional order flow analysis may use bid/ask data, footprint charts, or volume profiles. Because TradingView scripts cannot access true order-book data, this indicator instead uses proxy signals derived from standard chart data:
Delta (proxy): Estimated imbalance of buying vs. selling pressure, approximated using bar direction and volume.
Imbalance ratio: Normalizes delta by total volume, ranging between -1 and +1 in theory.
Cumulative Delta (CVD): Running sum of delta over time.
Effort vs. Result (EvR): A comparison between volume and actual bar movement, highlighting cases where large effort produced little result (or vice versa).
These are not real order-flow measurements, but rather simple mathematical constructs that mimic some of its logic.
How the Script Works
Detecting Break of Structure
The user specifies a swing length. When price closes above the recent high (for bullish BOS) or below the recent low (for bearish BOS), a potential shift is recorded.
To qualify, the breakout must exceed a displacement filter proportional to the ATR. This helps filter out weak moves.
Locating the Order Block Candle
Once a BOS is confirmed, the script looks back within a short window to find the last opposite-colored candle.
The high/low or open/close of that candle (depending on user settings) is marked as the potential order block zone.
Drawing and Maintaining Zones
Each order block is represented as a colored rectangle extending forward in time.
Bullish zones are teal by default, bearish zones are red.
Zones extend until invalidated (price closing or wicking beyond them, depending on user preference) or until a user-defined lifespan expires.
A pruning mechanism ensures that only the most recent set number of zones remain, preventing chart overload.
Monitoring Touches
The script checks whether the current bar’s range overlaps any existing order block.
If so, the “closest” zone is considered touched, and a label may appear on the chart.
Confirmation Filters
Touches can optionally be confirmed by order-flow proxies.
For a bullish confirmation, the following must align:
Imbalance ratio above threshold,
Delta EMA positive,
Effort vs. Result positive.
For a bearish confirmation, the opposite holds true.
Optionally, a higher-timeframe EMA slope filter can gate these confirmations. For example, a bullish confirmation may only be accepted if the higher-timeframe EMA is sloping upward.
Alerts
Users may create alerts based on conditions such as “bullish touch confirmed” or “bearish touch confirmed.”
Alerts can be gated to only fire after bar close, reducing intrabar noise.
Standard alertcondition calls are provided, and optional inline alert() calls can be enabled.
Inputs and Customization
Structure & OB
Swing length: Defines how many bars back to check for BOS.
ATR length & displacement factor: Adjust sensitivity for structural breaks.
Body vs. wick reference: Choose whether zones are based on candle bodies or full ranges.
Invalidation rule: Pick between wick breach or close beyond the level.
Lifespan (bars): Limit how long a zone remains active.
Max keep: Cap the number of zones stored to reduce clutter.
Order-Flow Proxies
Delta mode: Choose between “Close vs Previous Close” or “Body” for delta calculation.
EMA length: Smooths the delta/imbalance series.
Z-score lookback: Defines the averaging window for EvR.
Confirmation thresholds: Adjust the imbalance levels required for long/short confirmation.
Higher Timeframe Filter
Enable HTF gate: Optional filter requiring higher-timeframe EMA slope alignment.
HTF timeframe & EMA length: Configurable for context alignment.
Style
Colors and transparency for bullish and bearish zones.
Border color customization.
Alerts
Enable inline alerts: Optional direct calls to alert().
Alerts on bar close only: Helps avoid multiple firings during bar formation.
Practical Use
This tool is best seen as a way to annotate charts and to study how simple volume-derived signals behave near important structural levels. Some users may:
Observe whether order blocks line up with later price reactions.
Study how imbalance or cumulative delta conditions align with these zones.
Use it in a discretionary workflow to highlight areas of interest for deeper analysis.
Because the proxies are based only on candle OHLCV data, they are approximations. They cannot replace true depth-of-market analysis. Similarly, order block detection here is one specific algorithmic interpretation; other traders may define order blocks differently.
Limitations and Disclaimers
This indicator does not predict future price movement.
It does not access real order book or tick-by-tick data. All signals are derived from bar OHLCV.
Past performance of signals or zones does not guarantee future results.
The script is for educational and informational purposes only. It is not financial advice.
Users should test thoroughly, adjust parameters to their own instruments and timeframes, and use it in combination with broader analysis.
Summary
The Order Blocks + Order-Flow Proxies script is an experimental study tool that:
Detects potential order blocks using a displacement-filtered break of structure.
Marks these zones as boxes that persist until invalidation or expiry.
Provides lightweight order-flow-style proxies such as delta, imbalance, CVD, and effort vs. result.
Allows confirmation of zone touches through these proxies and optional higher-timeframe context.
Offers flexible customization, alerting, and chart-style options.
It is not a trading system by itself but rather a framework for studying price/volume behavior around structurally significant areas. With careful exploration, it can give users new ways to visualize market structure and to understand how simple flow-like measures behave in those contexts.
This indicator combines structural analysis of order blocks with lightweight order-flow style proxies, providing a tool for chart annotation and contextual study. It is designed to help users visualize where significant structural shifts occur and how simple volume-based signals behave around those areas. The script does not guarantee profitable outcomes, nor does it issue financial advice. It is intended purely for research, learning, and discretionary use.
Conceptual Background
Order Blocks
An “order block” is a term often used to describe a zone on the chart where price left behind a significant reversal or imbalance before continuing strongly in the opposite direction. In practice, this can mean the last bullish or bearish candle before a strong breakout. Traders sometimes study these regions because they believe that unfilled resting orders may exist there, or simply because they mark important pivots in price structure. This indicator detects such moments by scanning for breaks of structure (BOS). When price pushes above or below recent swing levels with sufficient displacement, the script identifies the prior opposite candle as the potential order block.
Break of Structure
A break of structure in this context is defined when the closing price moves beyond the highest high or lowest low of a short lookback window. The script compares the magnitude of this break to an ATR-based displacement filter. This helps ensure that only meaningful moves are marked rather than small, random fluctuations.
Order-Flow Proxies
Traditional order flow analysis may use bid/ask data, footprint charts, or volume profiles. Because TradingView scripts cannot access true order-book data, this indicator instead uses proxy signals derived from standard chart data:
Delta (proxy): Estimated imbalance of buying vs. selling pressure, approximated using bar direction and volume.
Imbalance ratio: Normalizes delta by total volume, ranging between -1 and +1 in theory.
Cumulative Delta (CVD): Running sum of delta over time.
Effort vs. Result (EvR): A comparison between volume and actual bar movement, highlighting cases where large effort produced little result (or vice versa).
These are not real order-flow measurements, but rather simple mathematical constructs that mimic some of its logic.
How the Script Works
Detecting Break of Structure
The user specifies a swing length. When price closes above the recent high (for bullish BOS) or below the recent low (for bearish BOS), a potential shift is recorded.
To qualify, the breakout must exceed a displacement filter proportional to the ATR. This helps filter out weak moves.
Locating the Order Block Candle
Once a BOS is confirmed, the script looks back within a short window to find the last opposite-colored candle.
The high/low or open/close of that candle (depending on user settings) is marked as the potential order block zone.
Drawing and Maintaining Zones
Each order block is represented as a colored rectangle extending forward in time.
Bullish zones are teal by default, bearish zones are red.
Zones extend until invalidated (price closing or wicking beyond them, depending on user preference) or until a user-defined lifespan expires.
A pruning mechanism ensures that only the most recent set number of zones remain, preventing chart overload.
Monitoring Touches
The script checks whether the current bar’s range overlaps any existing order block.
If so, the “closest” zone is considered touched, and a label may appear on the chart.
Confirmation Filters
Touches can optionally be confirmed by order-flow proxies.
For a bullish confirmation, the following must align:
Imbalance ratio above threshold,
Delta EMA positive,
Effort vs. Result positive.
For a bearish confirmation, the opposite holds true.
Optionally, a higher-timeframe EMA slope filter can gate these confirmations. For example, a bullish confirmation may only be accepted if the higher-timeframe EMA is sloping upward.
Alerts
Users may create alerts based on conditions such as “bullish touch confirmed” or “bearish touch confirmed.”
Alerts can be gated to only fire after bar close, reducing intrabar noise.
Standard alertcondition calls are provided, and optional inline alert() calls can be enabled.
Inputs and Customization
Structure & OB
Swing length: Defines how many bars back to check for BOS.
ATR length & displacement factor: Adjust sensitivity for structural breaks.
Body vs. wick reference: Choose whether zones are based on candle bodies or full ranges.
Invalidation rule: Pick between wick breach or close beyond the level.
Lifespan (bars): Limit how long a zone remains active.
Max keep: Cap the number of zones stored to reduce clutter.
Order-Flow Proxies
Delta mode: Choose between “Close vs Previous Close” or “Body” for delta calculation.
EMA length: Smooths the delta/imbalance series.
Z-score lookback: Defines the averaging window for EvR.
Confirmation thresholds: Adjust the imbalance levels required for long/short confirmation.
Higher Timeframe Filter
Enable HTF gate: Optional filter requiring higher-timeframe EMA slope alignment.
HTF timeframe & EMA length: Configurable for context alignment.
Style
Colors and transparency for bullish and bearish zones.
Border color customization.
Alerts
Enable inline alerts: Optional direct calls to alert().
Alerts on bar close only: Helps avoid multiple firings during bar formation.
Practical Use
This tool is best seen as a way to annotate charts and to study how simple volume-derived signals behave near important structural levels. Some users may:
Observe whether order blocks line up with later price reactions.
Study how imbalance or cumulative delta conditions align with these zones.
Use it in a discretionary workflow to highlight areas of interest for deeper analysis.
Because the proxies are based only on candle OHLCV data, they are approximations. They cannot replace true depth-of-market analysis. Similarly, order block detection here is one specific algorithmic interpretation; other traders may define order blocks differently.
Limitations and Disclaimers
This indicator does not predict future price movement.
It does not access real order book or tick-by-tick data. All signals are derived from bar OHLCV.
Past performance of signals or zones does not guarantee future results.
The script is for educational and informational purposes only. It is not financial advice.
Users should test thoroughly, adjust parameters to their own instruments and timeframes, and use it in combination with broader analysis.
Summary
The Order Blocks + Order-Flow Proxies script is an experimental study tool that:
Detects potential order blocks using a displacement-filtered break of structure.
Marks these zones as boxes that persist until invalidation or expiry.
Provides lightweight order-flow-style proxies such as delta, imbalance, CVD, and effort vs. result.
Allows confirmation of zone touches through these proxies and optional higher-timeframe context.
Offers flexible customization, alerting, and chart-style options.
It is not a trading system by itself but rather a framework for studying price/volume behavior around structurally significant areas. With careful exploration, it can give users new ways to visualize market structure and to understand how simple flow-like measures behave in those contexts.
Note di rilascio
update chartScript open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.