Smart Gap & Support and Resistance Breakout [MarkitTick]💡 This technical analysis script provides a highly sophisticated framework for market structure mapping, gap categorization, and breakout validation. By tracking structural pivot points and combining them with algorithmic gap analysis, the indicator systematically identifies areas of significant price imbalance and evaluates their impact on subsequent price action. The tool dynamically maps historical and developing support and resistance levels across multiple timeframes, integrating volume analysis and time-decay functions to ensure only the most relevant structural levels remain active. Designed for robust technical evaluation, it utilizes a strict non-repainting architecture for its multi-timeframe data retrieval, ensuring historical integrity during retrospective analysis.
✨ Originality and Utility
While many indicators plot basic support and resistance levels or highlight price gaps, this tool introduces a high degree of originality through its algorithmic synthesis and mashup methodology. The combination of structural pivot tracking and gap categorization is a deliberate and logical confluence. Gaps inherently represent sudden shifts in supply and demand, frequently acting as hidden support or resistance zones. By merging gap analysis with traditional pivot-based market structure, the script provides a unified view of market geometry.
Furthermore, the script distinguishes itself by categorizing gaps dynamically into three distinct types: Breakaway, Runaway, and Exhaustion. Rather than treating all price voids equally, it applies contextual logic—such as trend maturity and volume confirmation—to evaluate the probabilistic nature of the gap. The utility is further enhanced by an advanced multi-timeframe engine that overlays macro structural levels onto the active chart without introducing lookahead bias, providing traders with a pristine, top-down analytical perspective within a single pane.
🔬 Methodology and Concepts
● Structural Pivot Detection
The foundation of the script relies on identifying Swing Highs and Swing Lows.
A Pivot High is established when a specific high price is preceded and followed by a defined number of lower highs.
A Pivot Low is established when a specific low price is preceded and followed by a defined number of higher lows.
These points act as the empirical anchors for drawing support and resistance lines.
● Gap Categorization Engine
The script continuously scans for bullish and bearish price gaps (defined as a strict price void between the current low/high and the high/low of two bars prior, combined with directional candle confirmation). Once a gap exceeds the minimum size threshold, it is classified using the following methodology:
Breakaway Gaps (BW): Identified if the gap's occurrence coincides with the breaking of the most recently established structural pivot level. This signifies a forceful escape from a prior consolidation or trend phase.
Exhaustion Gaps (EX): Identified if the gap occurs after a prolonged trend duration (trend maturity) and is accompanied by a significant volume spike. This logic assumes that late-stage acceleration coupled with extreme volume often represents climatic buying or selling.
Runaway Gaps (RW): Any valid gap that does not meet the strict criteria for Breakaway or Exhaustion is classified as Runaway, representing standard trend continuation.
● Non-Repainting Multi-Timeframe Integration
To map higher timeframe (HTF) levels onto the lower timeframe (LTF) chart safely, the script employs a strict index-offset methodology. When fetching HTF pivot data, the script references the previous bar's calculated state while utilizing a lookahead parameter. This architectural design explicitly prevents future data leakage (lookahead bias), ensuring that historical backtesting and real-time execution behave identically.
● Breakout and Time-Decay Logic
Support and resistance lines are evaluated for breakouts based on closing prices. A breakout is only considered valid if the closing price decisively crosses the level and, if volume confirmation is enabled, the breakout bar's volume exceeds the defined moving average threshold. To maintain a clean visual workspace, levels can be subjected to a time-decay function, removing them from the chart after a user-defined number of bars.
🎨 Visual Guide
● Support and Resistance Lines
Green Lines: Represent active support levels derived from current timeframe pivot lows.
Red Lines: Represent active resistance levels derived from current timeframe pivot highs.
Thick Light Blue Lines: Highlight major support levels from the higher timeframe.
Thick Orange Lines: Highlight major resistance levels from the higher timeframe.
● Market Structure Labels
Red "HH" / "LH" Labels: Denote Higher Highs or Lower Highs at resistance pivots.
Blue/Green "LL" / "HL" Labels: Denote Lower Lows or Higher Lows at support pivots.
Purple "EH" / "EL" Labels: Indicate Equal Highs or Equal Lows.
● Gap Visualization Boxes
Blue Boxes: Highlight Breakaway Gaps (BW).
Orange Boxes: Highlight Runaway Gaps (RW).
Red Boxes: Highlight Exhaustion Gaps (EX).
Dotted Mid-Lines: Each gap box contains a dotted line calculating the exact mathematical midpoint of the gap, often acting as a highly reactive micro-level.
● Breakout Markers
Green Upward Triangles (▲): Plotted below the price to indicate a confirmed breakout of a resistance level. The number indicates how many distinct resistance levels were broken on that bar.
Red Downward Triangles (▼): Plotted above the price to indicate a confirmed breakdown of a support level.
Cyan/Orange Triangles: Represent breakouts of higher timeframe (HTF) levels.
📖 How to Use
● Interpreting Gap Signals
Breakaway Gaps: When a blue Breakaway gap forms, it suggests the initiation of a new directional phase. Traders typically monitor the borders of this gap to act as strong support or resistance upon any subsequent retests.
Runaway Gaps: The appearance of an orange Runaway gap confirms underlying trend strength. The midpoint of these gaps (the dotted line) is often used to gauge short-term trend health.
Exhaustion Gaps: A red Exhaustion gap serves as a cautionary signal. Because it indicates mature trend fatigue coupled with high volume, it suggests that the current directional momentum may be nearing a terminal phase or sharp retracement.
● Trading Support and Resistance Breakouts
Structural Mapping: Use the dynamically drawn S/R lines to identify the boundaries of the current market range.
Volume Confirmation: When the indicator plots a breakout triangle, ensure that it aligns with your broader directional bias. If the volume confirmation setting is active, the triangle inherently signifies that the breakout possessed above-average participation, increasing the mathematical probability of continuation.
Multi-Timeframe Confluence: Pay special attention when current timeframe price action interacts with the thicker HTF lines. A breakout that fractures both a LTF and HTF resistance level simultaneously carries significantly more structural weight.
⚙️ Inputs and Settings
● Swing Logic
Left Bars / Right Bars: Determines the number of bars required on either side of a candle to confirm a structural pivot. Higher values yield longer-term, more significant levels.
Max Stored Levels: Controls how many historical S/R lines remain active on the chart to prevent visual clutter.
Max Break Labels: Limits the number of historical breakout triangle markers displayed.
● Usability and Time Decay
Multi-Timeframe: Allows overriding the base timeframe for calculations.
Enable Time Decay: When activated, S/R levels that remain untested or unbroken will automatically expire and be removed from the chart.
Decay Period (Bars): The specific threshold of bars after which an untested level is deleted.
● Higher Timeframe (HTF) Levels
Enable HTF Levels: Toggles the calculation and plotting of macro S/R lines.
HTF Timeframe: The target timeframe for macro structural analysis (e.g., Daily, Weekly).
Hide Current TF When HTF Active: A visual filter to isolate only macro levels when desired.
● Algorithmic Filters and Analysis
Volume Confirmation: When true, breakouts are only validated if the bar's volume exceeds a moving average.
Min Gap Size (Points): Establishes a raw point threshold that a price void must exceed to be classified as a gap, filtering out negligible price skips.
Volume Spike Multiplier: The factor by which current volume must exceed the average to trigger Exhaustion gap logic.
Trend Maturity (Bars): The minimum number of bars a trend must have persisted from the last major pivot to allow for an Exhaustion gap classification.
🔍 Deconstruction of the Underlying Scientific and Academic Framework
● Auction Market Theory and Liquidity Voids
The gap categorization matrix within this script is deeply rooted in Auction Market Theory (AMT). In AMT, price discovery is a continuous auction searching for liquidity. A gap represents a structural liquidity void—a pricing zone where no double-sided auction occurred due to extreme urgency from either buyers or sellers. The script's identification of Breakaway gaps mathematically isolates moments where this urgency successfully overcomes historical supply or demand nodes (the pivots). The dotted midpoint lines inside the gap boxes serve as theoretical "Fair Value" approximations for the void, representing the mean reversion target if the market attempts to repair the inefficient auction.
● Volume Spread Analysis (VSA) Integration
The Exhaustion gap classification heavily relies on principles derived from Volume Spread Analysis. In VSA, volume represents the effort of market participants, while price spread represents the result. The script mathematically quantifies an anomaly: when an extended trend (measured by the Trend Maturity parameter) produces a sudden gap on extreme volume (measured by the Volume Spike Multiplier), it implies climactic transfer of inventory from strong hands to weak hands. The algorithmic detection of these specific variables provides a quantifiable method for identifying trend exhaustion without relying on lagging, bounded oscillators.
● Fractal Market Geometry
By rendering both LTF and HTF structural pivots within the same visual plane, the script operationalizes the concept of fractal market geometry. Financial time series exhibit self-similarity across different scales. A pivot high on a 15-minute chart is formed by the same behavioral mechanics as a pivot high on a Daily chart, but they carry vastly different liquidity weights. The script's strict index-offset MTF architecture ensures that the geometric relationship between these distinct fractal layers is evaluated with absolute temporal accuracy, providing a mathematically sound representation of macro supply and demand overlaying micro price action.
⚠️ 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.
Indicador Pine Script®






















