OPEN-SOURCE SCRIPT
BTC CME Gaps Detector [SwissAlgo]

BTC CME Gaps Detector [SwissAlgo]
Track Unfilled Gaps & Identify Price Magnets
------------------------------------------------------
Overview
The BTC CME Gap Detector identifies and tracks unfilled price gaps on any timeframe (1-minute recommended for scalping) to gauge potential trading bias.
Verify Gap Behavior Yourself: Use TradingView's Replay Mode on the 1-Minute chart to observe how the price interacts with gaps. Load the BTC1! ticker (Bitcoin CME Futures), enable Replay Mode, and play forward through time (for example: go back 15 days). You may observe patterns such as price frequently returning to fill gaps, nearest gaps acting as near-term targets, and gaps serving as potential support/resistance zones. Some gaps may fill quickly, while others may remain open for longer periods. This hands-on analysis lets you independently assess how gaps may influence price movement in real market conditions and whether you may use this indicator as a complement to your trading analysis.
------------------------------------------------------
Purpose
Price gaps occur when there is a discontinuity between consecutive candles - when the current candle's low is above the previous candle's high (gap up), or when the current candle's high is below the previous candle's low (gap down).
This indicator identifies and tracks these gaps on any timeframe to help traders:
------------------------------------------------------
Why Use This Indicator?


------------------------------------------------------
Trading Concept
Gaps represent price zones where no trading occurred. Historical market behavior suggests that unfilled gaps may attract price action as markets tend to revisit areas of incomplete price discovery. This phenomenon creates potential trading opportunities:
This indicator helps quantify gap proximity and provides a visual reference for these potential target zones.
EXAMPLE
Step 1: Bearish Gaps Appear Below Price

Step 2: Price Getting Close to Fill Gap

Step 3: Gap Mitigated Gap

------------------------------------------------------
Recommended Setup
Timeframe: 1-minute chart recommended for maximum gap detection frequency. Works on all timeframes (higher timeframes will show fewer, larger gaps).
Symbol: Any tradable instrument. Originally designed for BTC1! (CME Bitcoin Futures) but compatible with all symbols.
Settings:
------------------------------------------------------
How It Works
Gap Detection: Identifies price discontinuities on every candle where:
Mitigation Tracking: Monitors when price touches both gap boundaries. A gap is marked as filled when the price has touched both the top and bottom of the gap zone, even if this occurs across multiple candles.
Visual Elements:
Analysis Table: Shows:
------------------------------------------------------
Key Features
------------------------------------------------------
Disclaimer
This indicator is provided for informational and educational purposes only.
It does not constitute financial advice, investment recommendations, or trading signals. The concept that gaps attract price is based on historical observation and does not guarantee future results.
Gap fills are not certain - gaps may remain unfilled indefinitely, or the price may reverse before reaching a gap. This indicator should not be used as the sole basis for trading decisions.
All trading involves substantial risk, including the potential loss of principal. Users should conduct their own research, apply proper risk management, test strategies thoroughly, and consult with qualified financial professionals before making trading decisions.
The authors and publishers are not responsible for any losses incurred through the use of this indicator.
Track Unfilled Gaps & Identify Price Magnets
------------------------------------------------------
Overview
The BTC CME Gap Detector identifies and tracks unfilled price gaps on any timeframe (1-minute recommended for scalping) to gauge potential trading bias.
Verify Gap Behavior Yourself: Use TradingView's Replay Mode on the 1-Minute chart to observe how the price interacts with gaps. Load the BTC1! ticker (Bitcoin CME Futures), enable Replay Mode, and play forward through time (for example: go back 15 days). You may observe patterns such as price frequently returning to fill gaps, nearest gaps acting as near-term targets, and gaps serving as potential support/resistance zones. Some gaps may fill quickly, while others may remain open for longer periods. This hands-on analysis lets you independently assess how gaps may influence price movement in real market conditions and whether you may use this indicator as a complement to your trading analysis.
------------------------------------------------------
Purpose
Price gaps occur when there is a discontinuity between consecutive candles - when the current candle's low is above the previous candle's high (gap up), or when the current candle's high is below the previous candle's low (gap down).
This indicator identifies and tracks these gaps on any timeframe to help traders:
- Identify gap zones that may attract price (potential "price magnets")
- Monitor gap fill progression
- Assess potential directional bias based on nearest unfilled gaps (long, short)
- Analyze market structure and liquidity imbalances
------------------------------------------------------
Why Use This Indicator?
- Universal Gap Detection: Identifies all gaps on any timeframe (1-minute, hourly, daily, etc.)
- Multi-Candle Mitigation Tracking: Detects gap fills that occur across multiple candles
- Distance Analysis: Shows percentage distance to nearest bullish and bearish gaps
- Visual Representation: Color-coded boxes indicate gap status (active vs. mitigated)
- Age Filtering: Option to display only gaps within specified time periods (3/6/12/24 months), as older gaps may lose relevance
- ATR-Based Sizing: Minimum gap size adjusts to instrument volatility to filter noise (i.e. small gaps)
------------------------------------------------------
Trading Concept
Gaps represent price zones where no trading occurred. Historical market behavior suggests that unfilled gaps may attract price action as markets tend to revisit areas of incomplete price discovery. This phenomenon creates potential trading opportunities:
- Bullish gaps (above current price) may act as upside targets where the price could move to fill the gap
- Bearish gaps (below current price) may act as downside targets where price could move to fill the gap
- The nearest gap often provides directional bias, as closer gaps may have a higher probability of being filled in the near term
This indicator helps quantify gap proximity and provides a visual reference for these potential target zones.
EXAMPLE
Step 1: Bearish Gaps Appear Below Price
Step 2: Price Getting Close to Fill Gap
Step 3: Gap Mitigated Gap
------------------------------------------------------
Recommended Setup
Timeframe: 1-minute chart recommended for maximum gap detection frequency. Works on all timeframes (higher timeframes will show fewer, larger gaps).
Symbol: Any tradable instrument. Originally designed for BTC1! (CME Bitcoin Futures) but compatible with all symbols.
Settings:
- ATR Length: 14 (default)
- Min Gap Size: 0.5x ATR (adjust based on timeframe and noise level)
- Gap Age Limit: 3 months (configurable)
- Max Historical Gaps: 300 (adjustable 1-500)
------------------------------------------------------
How It Works
Gap Detection: Identifies price discontinuities on every candle where:
- Gap up: current candle low > previous candle high
- Gap down: current candle high < previous candle low
- Minimum gap size filter (ATR-based) eliminates insignificant gaps
Mitigation Tracking: Monitors when price touches both gap boundaries. A gap is marked as filled when the price has touched both the top and bottom of the gap zone, even if this occurs across multiple candles.
Visual Elements:
- Green boxes: Unfilled gaps above current price (potential bullish targets)
- Red boxes: Unfilled gaps below current price (potential bearish targets)
- Gray boxes: Filled gaps (historical reference)
- Labels: Display gap type, price level, and distance percentage
Analysis Table: Shows:
- Distance % to nearest bullish gap (above price)
- Distance % to nearest bearish gap (below price)
- Trade bias (LONG if nearest gap is above, SHORT if nearest gap is below)
------------------------------------------------------
Key Features
- Detects gaps on any timeframe (1m, 5m, 1h, 1D, etc.)
- Boxes extend 500 bars forward for active gaps, stop at the fill bar for mitigated gaps
- Real-time distance calculations update on every candle
- Configurable age filter removes outdated gaps
- ATR multiplier ensures gap detection adapts to market volatility and timeframe
------------------------------------------------------
Disclaimer
This indicator is provided for informational and educational purposes only.
It does not constitute financial advice, investment recommendations, or trading signals. The concept that gaps attract price is based on historical observation and does not guarantee future results.
Gap fills are not certain - gaps may remain unfilled indefinitely, or the price may reverse before reaching a gap. This indicator should not be used as the sole basis for trading decisions.
All trading involves substantial risk, including the potential loss of principal. Users should conduct their own research, apply proper risk management, test strategies thoroughly, and consult with qualified financial professionals before making trading decisions.
The authors and publishers are not responsible for any losses incurred through the use of this indicator.
Script de código aberto
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Aviso legal
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Script de código aberto
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Aviso legal
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.