CME Gap Magnet [AGPro Series]

🧠 Core Idea
When price drifts away from an unfilled CME futures gap, how strongly is it being pulled back toward it - and where is the fill, the risk, and the invalidation?
📌 Overview / What it does
CME Gap Magnet is a planner-style decision tool built specifically around CME Bitcoin and Ether futures gaps. It pulls the gap structure from the CME futures feed (for example CME:BTC1! and CME:ETH1!), then projects each unfilled gap onto your spot or perpetual crypto chart as a magnet zone. These are gaps that exist on the regulated futures session - they are not the ordinary opening or session gaps of the chart symbol itself.
For the nearest unfilled gap, the tool measures how far price currently sits from it (in daily-ATR units), converts that distance into a 0-100 pull score, and frames the fill target, an invalidation level, and a reward-to-risk readout in a clean panel. As price moves, the state updates between Far, In Range, Approaching, and Filling.
What it does NOT do: it does not predict price direction, it does not guarantee that any gap will fill, it does not place or manage trades, and it does not generate buy or sell instructions. It is a visualization and structuring layer for a market structure that many crypto traders already watch.
🎯 Purpose & Design Philosophy
CME gaps are widely followed, but most tooling for them stops at drawing a single line on the chart. That tells you where a gap is, but not whether it currently matters, how strongly price is being drawn toward it, or where the structure would be invalidated.
This tool was built to turn that watched level into a structured, repeatable read: is the nearest gap close enough to be actionable, how strong is the pull right now, and what does the risk framing look like. It is aimed at the discretionary crypto trader who already tracks CME gaps and wants a consistent way to evaluate them rather than eyeballing a line.
⚡ Why This Script Is Different
Most CME-gap tools simply draw a line or a box at the gap and leave interpretation entirely to the user. Many general gap tools, in turn, focus on the reaction once price is already inside a gap, or on whether a gap continues.
This script does NOT just mark a level, and it does NOT score the reaction once price is sitting in the zone.
Instead it models the gap as a magnet: it scores the pull by distance (how far price is from the unfilled gap, in daily-ATR units), tracks each gap's fill lifecycle directionally, and frames target, invalidation, and reward-to-risk for the nearest gap. Because the core distance and risk math is anchored to the daily timeframe, the panel reads consistently whether you view the chart on 1D, 4H, or 1H.
Two design choices keep it distinct and focused:
- Source: it reads CME futures gaps from an external security, so the gaps shown are the futures-session gaps - a different set from the chart symbol's own gaps.
- Model: it is a distance / pull model, not a reaction-quality-at-the-zone model.
⚙️ Methodology
1. CME source mapping
The chart's base currency is mapped to its CME future automatically (BTC and XBT to CME:BTC1!, ETH to CME:ETH1!), or a custom CME symbol can be set manually.
2. Session-break gap detection
Gaps are detected on the daily futures series by comparing each session's open to the prior session's close. A weekend / holiday option keeps only gaps that open after a non-trading break, identified by the elapsed time between consecutive sessions rather than a fixed weekday, so it stays robust to how the feed labels the post-break session.
3. Directional fill tracking
A gap-up is treated as filled when price trades back down to the prior close; a gap-down when price trades back up to it. Fill status is judged on the CME daily range, so the set of open gaps stays the same across chart timeframes.
4. Magnet scoring & risk framing
Distance to the nearest unfilled gap is measured in daily-ATR units and converted to a 0-100 pull score that fades as the gap gets farther away. The fill target, an ATR-based invalidation level, and a reward-to-risk value are derived for the nearest gap when it is within range.
5. Visual output
Open gaps are drawn as vivid magnet zones with the nearest one highlighted; resolved (filled) gaps remain as quiet context zones. A compact panel summarizes the decision state.
🗺️ How to Read the Chart
- Vivid zone = an open (unfilled) CME gap. The nearest one is highlighted as the Target.
- Muted slate zone = a gap that has already been filled, kept as light context.
- Zone label = the gap's size in percent plus its state (Target / Open / Filled).
- Dotted line = the magnet line from current price to the nearest unfilled gap.
- Panel = the decision summary (nearest gap, direction, pull score, state, action, gap size, invalidation, reward-to-risk, distance, open-gap count).
🚦 Signals & States
- None -> no unfilled gap is currently tracked.
- Far / Out of range -> a gap exists but sits beyond the pull range.
- In Range / Pull active -> the nearest gap is within an actionable distance.
- Approaching -> price is within the approach distance of the nearest gap.
- Filling -> price is currently inside the nearest gap zone.
These describe context. They are not promises and not trade commands.
🔔 Alerts Logic
- New CME Gap -> fires when a new unfilled gap is recorded.
- Gap Fill Started -> fires when price first enters the nearest gap zone.
- Strong Magnet Pull -> fires when the pull score crosses into the high band (66+).
Alerts are attention markers, not trade instructions.
🧩 Confluence Logic (optional)
The read becomes stronger when several conditions align: a small distance, a high pull score, and an Approaching or Filling state together describe a more developed context than any single value on its own.
📊 When to Use
- Trending pullbacks that drift back toward an unfilled gap.
- Range conditions where an edge sits near a gap.
- Sessions following a weekend or holiday break, when fresh gaps are most relevant.
⚠️ When NOT to Use
- Thin-liquidity conditions where prints are unreliable.
- High-impact news or extreme volatility, where structure can be overwhelmed.
- When there is no open gap - the panel will state this clearly, and the tool simply has nothing to frame.
🎛️ Key Inputs
- Gap Source: auto-match CME symbol or a custom symbol, gap timeframe, weekend/holiday-only filter, minimum gap size, and maximum tracked gaps.
- Magnet & Risk: pull range (in ATR), approach distance (in ATR), invalidation buffer (in ATR), and ATR length.
- Display: panel theme (Dark/Light), panel location, panel and label font sizes, and toggles for the panel, gap zones, magnet line, and filled gaps.
- Labels & Performance: how many bars zones project forward, and the calculation window.
🖥️ Interface & Visual Design
A single merged header row carries the tool name, followed by the decision rows. Open zones use vivid state colors with the nearest gap highlighted, while filled zones use a muted slate tone so the active context stands out first. Label spacing scales with the chart so labels stay readable and do not overlap on zoomed-out views.
🧪 Practical Usage Workflow
1. Read the panel: note the state and the pull score.
2. Locate the nearest gap zone and the magnet line.
3. Check the distance and the reward-to-risk framing.
4. Confirm the context against your own structure and plan before acting.
🔍 Interpretation Guidelines
Treat the pull score as a relative gauge of distance-based pull, not a probability. A higher score means the gap is closer and the pull is stronger in relative terms - it does not mean a fill is likely or imminent. Always read it together with broader market structure.
🚫 What This Script Is NOT
- Not a prediction engine.
- Not financial advice.
- Not an automated trading system.
- Not a source of guaranteed signals or guaranteed gap fills.
⚠️ Limitations & Transparency
- It depends on CME futures data being available on your TradingView plan and symbol; if the feed is unavailable, the panel will say so.
- The chart timeframe affects how much history and how many zones are visible.
- Gaps may remain unfilled indefinitely, and price can reverse before reaching a gap.
- It is a rule-based analytical tool; it does not adapt to news, slippage, spread changes, or sudden liquidity shifts.
🧠 Market Context Notes (optional)
CME gaps arise from the difference between one regulated futures session's close and the next session's open, most often across the weekend. Many traders watch them as reference levels that price has historically tended to revisit, while understanding that this is an observation, not a rule.
🧾 Use Case Examples (optional)
- Price is trending down toward an unfilled gap below, the pull score is rising, and the state turns Approaching - context for watching how price behaves near the level.
- Price enters the nearest gap zone and the state turns Filling - the tool marks that the gap is being tested, leaving the read to the user.
- The nearest gap sits far above price with a low score - the gap stays on the map as context but is not framed as an actionable setup.
🧱 System Philosophy (advanced)
AGProLabs tools are built around structured interpretation: take a market structure traders already watch, and turn it into a consistent, repeatable read with clear context and clear limitations - rather than another opaque signal.
🔐 Non-Promise Statement
This tool offers no guarantees and no certainty about gap fills or price direction. It organizes information; it does not foresee outcomes.
📉 Risk Disclosure
Trading involves substantial risk, including the possible loss of capital. This script is for educational and analytical purposes only and does not constitute financial advice. Users remain responsible for their own research, risk management, position sizing, and decisions.
📚 Educational Note
The best use of this tool is not to chase every gap, but to slow the decision process down: read the distance, the state, and the risk framing, and decide whether the context is structured enough to deserve attention.
This update focuses on decision depth: turning a single proximity reading into a
transparent, multi-factor fill-readiness engine with an empirical statistics layer.
The core purpose of the script remains unchanged. It still detects unfilled CME
weekend gaps on Bitcoin and Ethereum and frames them as magnet targets. This
release deepens HOW that pull is measured and presented, and adds historical
context the previous version did not surface.
This script continues to function as an analytical and visualization tool. It does
not attempt to predict price direction or provide guaranteed outcomes.
------------------------
What Changed
------------------------
- New Fill Readiness score (0-100)
The single proximity-based "Pull Score" has been replaced by a transparent
composite that fuses five independent factors. The panel now shows each factor on
its own line, so the score is auditable rather than a black box.
- Five-factor breakdown
Proximity (distance in daily ATR), Momentum (is price moving toward the gap),
Freshness (gap age in days), Size (smaller gaps fill more readily) and Clearance
(other open gaps obstructing the path) each contribute to the composite.
- Empirical fill statistics
A new statistics block reports the historical fill rate across the tracked window
(with sample size n) and the median days-to-fill. These are measured from the
chart history, not assumed.
- Expected fill window
Using the median fill time and the current gap age, the panel prints an estimated
remaining window (for example "~4d"), or "Overdue" when a gap has already exceeded
the typical fill time.
- Target ladder
When a second unfilled gap sits beyond the nearest one on the same side, it is
marked as Target 2, so the next objective is visible at a glance.
- Live score tag on the magnet line
The active Fill Readiness value and expected fill window are printed directly on
the magnet line in the projection area, keeping the key number on-chart.
------------------------
Visual Improvements
------------------------
- Improved chart readability by centering each gap label inside its zone, both
vertically and horizontally, instead of parking it at the edge.
- Reduced visual clutter to enhance first-glance interpretation: open-gap labels
now also show gap age, and filled-gap labels are spacing-guarded so they never
stack on top of one another.
- Refined visual hierarchy so the active target zone (accent border, brighter fill)
clearly stands apart from secondary and filled gaps.
- Adjusted positioning of the score tag into the forward projection so the active
area of the chart carries the headline number rather than sitting empty.
------------------------
Interface & Usability
------------------------
- Restructured the panel into three readable blocks: Verdict, Factor Breakdown and
Plan & Statistics, separated by divider rows for clearer information flow.
- Reorganized inputs into a dedicated Readiness Engine group (momentum lookback,
aging horizon, reference gap size) so the scoring behavior is easy to tune.
- Adjusted default visual settings for a more balanced premium appearance.
- Enhanced overall user experience while keeping panel theme, location and font
size fully adjustable, with the panel shown by default.
------------------------
Behavior Notes
------------------------
This update changes how the readiness number is calculated, expanding it from one
factor to five, and adds empirical context. The underlying gap detection and
fill-tracking logic are unchanged.
The goal is to improve clarity, depth and usability, not to introduce predictive
behavior. The statistics describe past fills within the visible window and are not
forecasts.
Users should continue to interpret outputs as context, now with a more detailed
and auditable readout.
------------------------
Limitations Reminder
------------------------
The script remains a rule-based analytical tool.
Market conditions such as volatility, liquidity, timeframe differences and the
availability of the CME futures feed may affect how gaps and scores appear.
Outputs should always be interpreted within broader market context.
------------------------
Risk Reminder
------------------------
This script is for educational and analytical purposes only.
It does not provide financial advice or guaranteed trading outcomes.
Users remain responsible for their own decisions.
This update focuses on source-time alignment, fill-lifecycle integrity, timeframe transparency, interface clarity, and chart readability.
The core purpose of the script remains unchanged. CME Gap Magnet still maps Bitcoin and Ether futures gaps from the CME feed, maintains an open-gap set, ranks the nearest magnet through five Fill Readiness factors, and frames the active target with historical context and risk references.
This release corrects when existing gap and fill information becomes observable. It does not add prediction, automated execution, or guaranteed outcomes.
------------------------
What Changed
------------------------
• Source-open chronology
The current source-bar open and time, together with the confirmed previous source close, are now exposed from the start of the source bar. These values are already final at that moment, so this removes the lower-timeframe delay without importing future high, low, or close data.
• CME-resolution fill tracking
Fill evaluation now uses confirmed CME high/low data at the active chart resolution. V2.0 requested a developing daily range on every chart timeframe, which could delay historical lower-timeframe detection and could leave legitimate same-session fills classified as open.
• Same-source-bar fill support
A gap may now resolve during its opening source session when CME actually trades back through the prior-close edge. V2.0 required a later chart bar after the gap record was created, which could miss same-session fills when the daily source value became visible only at the end of the day.
• Confirmed state mutations
Gap creation, gap-fill state changes, and all three alerts are committed only after the chart bar closes. Developing real-time bars cannot create persistent gap or alert events before confirmation.
• Gap-timeframe compatibility
The compatibility check now compares the chart timeframe with the selected Gap Timeframe. A chart that is coarser than the gap source is clearly blocked because it can skip source openings. The panel reports “Chart TF > Gap TF” instead of assuming that Daily is the only possible source setting.
• Timeframe statement corrected
Daily ATR continues to normalize proximity and risk geometry across chart timeframes. The input tooltip now states explicitly that Momentum Lookback remains chart-timeframe based, so the complete Fill Readiness score is not presented as timeframe-invariant.
------------------------
Visual Improvements
------------------------
• Open, target, secondary-target, and filled badges now use compact uppercase wording.
• Gap badges use the premium single-line format “CME GAP | SIZE | STATE”.
• Active target badges append “F00” and the historical window without changing the underlying five-factor score.
• Filled-gap badges are now horizontally and vertically centered inside their zones.
• Bright bullish and bearish badges use dark contrast-safe text; filled slate badges retain light text.
• The magnet line now connects current price to the projected target area instead of remaining vertical on the current bar.
------------------------
Interface & Usability
------------------------
• The first panel row remains one merged blue header containing only “AG Pro CME Gap Magnet.”
• Action has been renamed Context, with neutral analytical wording such as High readiness, Momentum not aligned, and Readiness developing.
• State and direction wording now uses consistent premium uppercase formatting.
• Invalidation, Reward:Risk, and Est. Fill are presented as Risk Reference, Target:Risk, and Hist. Window to avoid implying a fixed order or a forecast.
• “Overdue” has been replaced by “Past median,” making clear that the value is a comparison with the historical median rather than a deadline.
• Disabling Show Panel now clears the entire table immediately, preventing stale rows from remaining visible.
• Panel theme, location, panel font size, label font size, zone, line, score-tag, and filled-gap controls remain available.
------------------------
Behavior Notes
------------------------
The five-factor Fill Readiness model, factor weights, ATR normalization, gap-size threshold, weekend/holiday filter, target ladder, auto CME mapping, and core magnet concept remain unchanged.
The open-gap set, nearest target, fill rate, median fill time, and sample size may change because fills are now evaluated from correctly aligned source-open chronology and confirmed CME bars. Same-session fills can legitimately produce a median of 0d on a daily chart.
Statistics remain dependent on the loaded Calculation Window. Lower chart timeframes cover less calendar history when the same number of chart bars is used.
------------------------
Limitations Reminder
------------------------
The script remains a rule-based analytical and visualization tool.
CME feed availability, contract-roll behavior, basis differences between CME futures and the chart symbol, chart timeframe, calculation window, volatility, and liquidity can affect displayed gaps, scores, and statistics.
Historical fill rate, median fill time, and the historical window describe the loaded sample. They are not forecasts or guaranteed probabilities.
------------------------
Risk Reminder
------------------------
This script is for educational and analytical purposes only.
It does not provide financial advice, automated execution, or guaranteed trading outcomes.
Users remain responsible for their own decisions and risk management.
• Refreshed the publication and access routing information.
• Core CME-gap magnet logic, panel behavior, inputs, alerts, visuals, and outputs remain unchanged.
This update focuses on decision clarity, statistical discipline, panel readability and collision-safe chart presentation.
The core purpose remains unchanged: identify and frame CME futures gaps as analytical magnet targets for Bitcoin and Ethereum charts.
------------------------
What Changed
------------------------
• Added a 90% Wilson confidence floor for the historical fill rate.
The panel now separates the observed fill rate from a conservative evidence floor, reducing overconfidence when sample sizes are limited.
• Added a standard decision question beneath the merged blue title:
WHICH CME GAP HAS THE STRONGEST FILL CASE?
• Rebuilt the panel into a tighter twenty-row decision stack with no decorative separator rows.
• Reframed the factor names as Fill Readiness, Gap Size Fit, Path Clearance, Risk Edge and Fill Timing for faster interpretation.
• Added horizontal and vertical collision checks to historical gap badges while preserving centered labels inside visible gap zones.
------------------------
Visual Improvements
------------------------
• Added opaque alternating panel rows for reliable contrast on light and dark charts.
• Added theme-specific panel state colors so values remain readable in both panel themes.
• Preserved the centered zone-label standard while suppressing avoidable badge collisions.
• Kept the chart populated with open, target and recently filled gap evidence without excessive clutter.
------------------------
Interface & Usability
------------------------
• Panel location, theme, visibility and font sizes remain adjustable.
• The title remains a single merged blue row.
• The decision question, live target, readiness factors, risk framing and historical evidence now follow a clearer top-to-bottom hierarchy.
------------------------
Behavior Notes
------------------------
The gap-detection, fill-tracking, readiness-factor and alert logic remain unchanged.
The new confidence floor is an additional statistical interpretation layer. It does not predict whether a specific gap will fill.
------------------------
Limitations Reminder
------------------------
CME feed access, chart timeframe, liquidity, volatility and the selected calculation window can affect detected gaps and historical statistics.
The observed fill rate and confidence floor describe the loaded sample only.
------------------------
Risk Reminder
------------------------
This script is an analytical and visualization tool.
It does not provide financial advice, automated execution or guaranteed trading outcomes.
This update focuses on first-glance target hierarchy, historical-gap spacing, and panel decision clarity while preserving the CME source mapping, directional gap-fill lifecycle, five-factor Fill Readiness engine, empirical statistics, risk framing, and alert behavior.
• Limited older secondary open-gap zones to a configurable recent display window, preventing legacy gaps from dominating the full chart while keeping the active nearest gap anchored to its true origin.
• Rebuilt the active gap badge as a centered two-line decision card that combines magnet direction, lifecycle state, Fill Readiness, gap size, and expected timing in one readable hierarchy.
• Shortened resolved-gap badges to a compact filled-state format so historical context remains legible without competing with the active target.
• Added a configurable 52-bar resolved-label cooldown and reduced the default resolved-gap display cap to three, removing clustered labels around candle bodies.
• Preserved one filled badge inside every displayed resolved zone, maintaining clear price ownership and the established zone-label relationship.
• Added a contrast-safe filled State cell to the panel so Filling, Approaching, In Range, Distant, and None conditions can be identified immediately.
• Hardened panel initialization by creating both title cells before the existing last-bar merge and rebuild sequence.
• Preserved the underlying gap detector, CME feed mapping, fill tracking, target selection, five scoring factors, Wilson confidence floor, median fill timing, risk calculations, and all three alert conditions.
Invite-only script
Only users approved by the author can access this script. You'll need to request and get permission to use it. This is typically granted after payment. For more details, follow the author's instructions below or contact AGProLabs directly.
TradingView does NOT recommend paying for or using a script unless you fully trust its author and understand how it works. You may also find free, open-source alternatives in our community scripts.
Author's instructions
tradingview.com/script/XJmX3p98-Trading-Suite-AGPro-Series/
🔷 Crypto Setup Planner - Multi-Symbol Planner
tradingview.com/script/LgVRo7Ql-Crypto-Setup-Planner-AGPro-Series/
Disclaimer
Invite-only script
Only users approved by the author can access this script. You'll need to request and get permission to use it. This is typically granted after payment. For more details, follow the author's instructions below or contact AGProLabs directly.
TradingView does NOT recommend paying for or using a script unless you fully trust its author and understand how it works. You may also find free, open-source alternatives in our community scripts.
Author's instructions
tradingview.com/script/XJmX3p98-Trading-Suite-AGPro-Series/
🔷 Crypto Setup Planner - Multi-Symbol Planner
tradingview.com/script/LgVRo7Ql-Crypto-Setup-Planner-AGPro-Series/