OPEN-SOURCE SCRIPT

Smart Gap Concepts [MarkitTick]

256
💡 This indicator automates the identification and classification of price gaps, commonly known as Fair Value Gaps (FVG) or Imbalances, by integrating market structure and volume analysis. Unlike standard gap detectors that simply highlight empty space on a chart, this script applies algorithmic filters to categorize gaps into three distinct phases of market movement: Breakaway, Runaway, and Exhaustion. This helps traders understand the potential context of a move rather than just seeing a support or resistance zone.

● Originality and Utility
The primary innovation of this tool is its dynamic classification system. It moves beyond visual detection by checking the "why" behind the gap. By referencing Swing Highs and Swing Lows (Market Structure) alongside Volume efficiency, it determines if a gap represents a breakout, a trend continuation, or a climatic end to a move. Additionally, the script features an automated mitigation tracking system that removes gaps from the chart once price has re-tested the midpoint, ensuring the visual workspace remains clean and relevant to current price action.

● Methodology
The script operates on a multi-stage logic engine:

• Gap Detection
It first identifies the core imbalance where the Low of the current bar does not overlap with the High of the bar two periods prior (for bullish gaps), ensuring the intervening candle represents a strong displacement.

• Structural Analysis (Breakaway Gaps)
The script monitors Pivot Highs and Lows. If a gap occurs simultaneously with a close beyond a key structural Pivot, it is classified as a "Breakaway Gap." This signals the potential start of a new trend.

• Volume and Time Analysis (Exhaustion Gaps)
To identify potential reversals, the script looks for "Trend Maturity." If a gap forms after a long duration since the last pivot and is accompanied by a volume spike (defined by the Volume Spike Multiplier), it is labeled as an "Exhaustion Gap."

• Continuation (Runaway Gaps)
If a gap is valid but meets neither the Breakaway nor Exhaustion criteria, it is considered a "Runaway Gap," typically found in the middle of an established trend.

• Dynamic Cleanup
The script tracks the midpoint of every active gap. If price creates a lower low (for bullish gaps) or higher high (for bearish gaps) beyond this midpoint, the gap is considered mitigated and is removed from the screen.

📖 How to Use
Traders can utilize the color-coded classifications to gauge market intent:

  • Breakaway (Default Blue): Watch these zones for potential trend initiations. These are often high-probability areas for a retest entry after a structure break.
  • Runaway (Default Orange): These indicate strong momentum. They can be used to trail stop-losses or add to winning positions, as price should ideally not close below these gaps in a healthy trend.
  • Exhaustion (Default Red): Be cautious when these appear. They suggest the current move is overextended and a reversal or complex pullback may be imminent.


• Exhaustion Gap : A Practical Case Study
snapshot
• Breakaway Gap: A Practical Case Study
snapshot
• Runaway Gap : A Practical Case Study
snapshot
⚙️ Inputs and Settings
  • Min Gap Size (Points): Filters out insignificant gaps smaller than this threshold.
  • Structure Lookback: Defines the sensitivity of the Pivot detection (Swing High/Low).
  • Volume Avg Length & Multiplier: Determines what qualifies as a "Volume Spike" for exhaustion logic.
  • Trend Maturity: The minimum number of bars required to consider a trend "old" enough for an exhaustion signal.
  • Visual Settings: Custom colors for each gap type and box extension length.



● Disclaimer
All provided scripts and indicators are strictly for educational exploration and must not be interpreted as financial advice or a recommendation to execute trades. I expressly disclaim all liability for any financial losses or damages that may result, directly or indirectly, from the reliance on or application of these tools. Market participation carries inherent risk where past performance never guarantees future returns, leaving all investment decisions and due diligence solely at your own discretion.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.