PROTECTED SOURCE SCRIPT
Orderflow [Pro+] (DeadCat)

This indicator introduces a sophisticated, multi-timeframe approach to detecting and visualizing Fair Value Gaps (FVGs)—also known as price imbalances—in order flow analysis. FVGs represent inefficiencies in price delivery where rapid buying or selling pressure creates a "gap" between candles, often signaling areas where price is likely to return to "fill" the imbalance due to unfilled liquidity. Unlike basic single-timeframe FVG tools that simply highlight gaps without context, this script layers in hierarchical time-based rules (HTF influencing LTF) to filter noise, enforce directional bias, and project dynamic support/resistance levels post-mitigation.
The core innovation lies in its bias-driven ecosystem: Higher timeframes (HTF) establish a "master bias" (bullish or bearish) upon FVG mitigation, which then governs lower timeframes (LTF) by suppressing conflicting FVGs or deleting overlapping ones. This creates a cascading structure where, for example, a bullish daily FVG might invalidate bearish 15-minute gaps above its bottom edge, promoting confluence across scales. Additionally, it incorporates dynamic swing tracking (updating highs/lows in real-time post-mitigation) and overlapping liquidity lines (projecting prior swings trapped within the FVG), turning static gap detection into a proactive order flow mapper.
This isn't a mere mashup of standard FVG logic (e.g., 3-candle imbalance checks) or swing detectors; the components synergize to simulate institutional order flow dynamics—prioritizing liquidity sweeps and bias alignment—reducing false signals in choppy markets. It's designed for traders seeking edge in scalping, swing, or position trading without repainting or lookahead bias in historical data.
Key Concepts Underlying the Calculations
FVG Detection Mechanism:
Uses a classic 3-candle imbalance filter: For a bullish FVG, the low of the current bar must gap above the high of the bar two periods ago (low[0] > high[2]), with the prior bar's low dipping below that high (low[1] < high[2]) to confirm inefficiency. The inverse applies for bearish FVGs (high[0] < low[2], high[1] > low[2]).
Introduces a BAG filter (Bias-Aligned Gap): Checks if the close of the confirming candle aligns with the gap's midpoint (e.g., close > midpoint for bullish), discarding "weak" gaps where price closes against the expected direction. This refines raw imbalances to those backed by momentum.
Swing Identification and Projection:
Tracks fixed swings (static high/low from the FVG formation bar) and dynamic swings (updating to new extremes post-mitigation, e.g., highest high since a bullish FVG touch).
Equal Range Lines (ERL): Post-mitigation, projects horizontal lines from fixed/dynamic swings as potential support (bullish) or resistance (bearish). These extend rightward until breached, with optional pre-tap visibility for anticipation.
Overlapping Liquidity: Scans the 5-bar lookback within the FVG range for trapped highs/lows, drawing a dotted line to highlight "engineered liquidity" zones where stops might cluster.
Hierarchical Bias Rules (HTF-LTF Interaction):
Once an FVG is mitigated (price touches its opposite edge, e.g., low piercing a bullish FVG's top), it activates a bias state for that timeframe (bullish: +1; bearish: -1), storing the gap's bounds as a reference.
LTF Suppression: New LTF FVGs opposing the HTF bias are blocked if they form in invalid zones (e.g., bearish LTF FVG bottom > bullish HTF bottom). Existing LTF FVGs are deleted if engulfed, partially overlapped, or directionally misaligned (6 overlap rules, including full engulfment or same-direction displacement).
Reset Triggers: Bias resets on opposing swing breaks (e.g., low < fixed swing in bullish state) or exhaustive mitigation (all FVGs filled), ensuring adaptability.
Mitigation and Extension Logic:
FVGs extend as semi-transparent boxes until fully mitigated (price closes beyond the far edge), then halt extension and optionally change color (e.g., red tint for filled zones).
Current-timeframe FVGs shift left by 2 bars to align with real-time bar indexing, avoiding visual lag.
These concepts draw from ICT (Inner Circle Trader) order flow principles—focusing on liquidity voids and bias hierarchies—but implement them programmatically with cross-TF validation, which isn't standard in most FVG scripts.
How It Works: Step-by-Step Signal Generation
Data Fetching: Pulls OHLCV from up to 6 user-defined timeframes (default: 15m, 1H, 4H, D, W, M) using request.security with barmerge to sync HTF bars to LTF without gaps.
FVG Formation: On each HTF bar close, scans for imbalances. If valid (post-bias filter), initializes state: clears prior opposing data, sets fixed/dynamic swings, and draws the box from formation time to infinity.
Ongoing Updates:
Boxes/labels/midlines extend rightward.
Swings update dynamically if new highs/lows form post-mitigation.
HTF bias propagates downward, pruning LTF noise in real-time.
Mitigation Check: On every LTF bar, tests if price pierces the nearest FVG edge. If so, activates bias, projects ERLs/overlaps, and cascades deletions.
Visualization: Boxes (FVGs) with midlines/labels; solid/dashed ERLs for swings; dotted overlaps. Optional table summarizes bias status (e.g., "▲ bullish IRL reacting" if price respects the level).
No future data is used—calculations are historical and real-time safe. Max limits (500 boxes/lines/labels) prevent overload.
How to Use It: Practical Application
Setup: Add to your chart (overlay=true). Enable 2-4 timeframes for confluence (e.g., 15m for entries, 1H/4H for bias). Set biases to "Auto" for dynamic detection, or "▲"/"▼" to force bullish/bearish filtering. Use universal colors for clean multi-TF overlays; tweak line styles/widths for visibility.
Interpretation:
Watch for FVGs: Bullish (upward gap, blue box) suggests buy-side inefficiency—expect pullbacks to fill from above. Bearish (downward gap) indicates sell pressure.
Bias Alignment: Green table status (e.g., "▲ reacting") signals strength; red ("failing") warns of reversal. Prioritize trades where LTF FVGs align with HTF bias.
Entry/Exit Ideas: Enter longs on bullish FVG mitigation (low touches top, ERL projects support). Target the box bottom or dynamic swing. Exit on bias reset (opposing break).
Risk Management: FVGs act as dynamic S/R. Use overlaps for stop placement (e.g., below trapped low). Avoid non-standard charts (Heikin Ashi) as signals distort.
Backtest with realistic slippage (0.1-0.5%) and risk <2% per trade. Past fills don't guarantee future ones—always combine with discretion.
Disclaimer: For educational purposes. Not financial advice. Verify in a demo account.
The core innovation lies in its bias-driven ecosystem: Higher timeframes (HTF) establish a "master bias" (bullish or bearish) upon FVG mitigation, which then governs lower timeframes (LTF) by suppressing conflicting FVGs or deleting overlapping ones. This creates a cascading structure where, for example, a bullish daily FVG might invalidate bearish 15-minute gaps above its bottom edge, promoting confluence across scales. Additionally, it incorporates dynamic swing tracking (updating highs/lows in real-time post-mitigation) and overlapping liquidity lines (projecting prior swings trapped within the FVG), turning static gap detection into a proactive order flow mapper.
This isn't a mere mashup of standard FVG logic (e.g., 3-candle imbalance checks) or swing detectors; the components synergize to simulate institutional order flow dynamics—prioritizing liquidity sweeps and bias alignment—reducing false signals in choppy markets. It's designed for traders seeking edge in scalping, swing, or position trading without repainting or lookahead bias in historical data.
Key Concepts Underlying the Calculations
FVG Detection Mechanism:
Uses a classic 3-candle imbalance filter: For a bullish FVG, the low of the current bar must gap above the high of the bar two periods ago (low[0] > high[2]), with the prior bar's low dipping below that high (low[1] < high[2]) to confirm inefficiency. The inverse applies for bearish FVGs (high[0] < low[2], high[1] > low[2]).
Introduces a BAG filter (Bias-Aligned Gap): Checks if the close of the confirming candle aligns with the gap's midpoint (e.g., close > midpoint for bullish), discarding "weak" gaps where price closes against the expected direction. This refines raw imbalances to those backed by momentum.
Swing Identification and Projection:
Tracks fixed swings (static high/low from the FVG formation bar) and dynamic swings (updating to new extremes post-mitigation, e.g., highest high since a bullish FVG touch).
Equal Range Lines (ERL): Post-mitigation, projects horizontal lines from fixed/dynamic swings as potential support (bullish) or resistance (bearish). These extend rightward until breached, with optional pre-tap visibility for anticipation.
Overlapping Liquidity: Scans the 5-bar lookback within the FVG range for trapped highs/lows, drawing a dotted line to highlight "engineered liquidity" zones where stops might cluster.
Hierarchical Bias Rules (HTF-LTF Interaction):
Once an FVG is mitigated (price touches its opposite edge, e.g., low piercing a bullish FVG's top), it activates a bias state for that timeframe (bullish: +1; bearish: -1), storing the gap's bounds as a reference.
LTF Suppression: New LTF FVGs opposing the HTF bias are blocked if they form in invalid zones (e.g., bearish LTF FVG bottom > bullish HTF bottom). Existing LTF FVGs are deleted if engulfed, partially overlapped, or directionally misaligned (6 overlap rules, including full engulfment or same-direction displacement).
Reset Triggers: Bias resets on opposing swing breaks (e.g., low < fixed swing in bullish state) or exhaustive mitigation (all FVGs filled), ensuring adaptability.
Mitigation and Extension Logic:
FVGs extend as semi-transparent boxes until fully mitigated (price closes beyond the far edge), then halt extension and optionally change color (e.g., red tint for filled zones).
Current-timeframe FVGs shift left by 2 bars to align with real-time bar indexing, avoiding visual lag.
These concepts draw from ICT (Inner Circle Trader) order flow principles—focusing on liquidity voids and bias hierarchies—but implement them programmatically with cross-TF validation, which isn't standard in most FVG scripts.
How It Works: Step-by-Step Signal Generation
Data Fetching: Pulls OHLCV from up to 6 user-defined timeframes (default: 15m, 1H, 4H, D, W, M) using request.security with barmerge to sync HTF bars to LTF without gaps.
FVG Formation: On each HTF bar close, scans for imbalances. If valid (post-bias filter), initializes state: clears prior opposing data, sets fixed/dynamic swings, and draws the box from formation time to infinity.
Ongoing Updates:
Boxes/labels/midlines extend rightward.
Swings update dynamically if new highs/lows form post-mitigation.
HTF bias propagates downward, pruning LTF noise in real-time.
Mitigation Check: On every LTF bar, tests if price pierces the nearest FVG edge. If so, activates bias, projects ERLs/overlaps, and cascades deletions.
Visualization: Boxes (FVGs) with midlines/labels; solid/dashed ERLs for swings; dotted overlaps. Optional table summarizes bias status (e.g., "▲ bullish IRL reacting" if price respects the level).
No future data is used—calculations are historical and real-time safe. Max limits (500 boxes/lines/labels) prevent overload.
How to Use It: Practical Application
Setup: Add to your chart (overlay=true). Enable 2-4 timeframes for confluence (e.g., 15m for entries, 1H/4H for bias). Set biases to "Auto" for dynamic detection, or "▲"/"▼" to force bullish/bearish filtering. Use universal colors for clean multi-TF overlays; tweak line styles/widths for visibility.
Interpretation:
Watch for FVGs: Bullish (upward gap, blue box) suggests buy-side inefficiency—expect pullbacks to fill from above. Bearish (downward gap) indicates sell pressure.
Bias Alignment: Green table status (e.g., "▲ reacting") signals strength; red ("failing") warns of reversal. Prioritize trades where LTF FVGs align with HTF bias.
Entry/Exit Ideas: Enter longs on bullish FVG mitigation (low touches top, ERL projects support). Target the box bottom or dynamic swing. Exit on bias reset (opposing break).
Risk Management: FVGs act as dynamic S/R. Use overlaps for stop placement (e.g., below trapped low). Avoid non-standard charts (Heikin Ashi) as signals distort.
Backtest with realistic slippage (0.1-0.5%) and risk <2% per trade. Past fills don't guarantee future ones—always combine with discretion.
Disclaimer: For educational purposes. Not financial advice. Verify in a demo account.
Skrypt chroniony
Ten skrypt został opublikowany jako zamknięty kod źródłowy. Możesz jednak używać go swobodnie i bez żadnych ograniczeń – więcej informacji tutaj.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt chroniony
Ten skrypt został opublikowany jako zamknięty kod źródłowy. Możesz jednak używać go swobodnie i bez żadnych ograniczeń – więcej informacji tutaj.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.