PROTECTED SOURCE SCRIPT
Aggiornato

DB - CME Gap [Multi Asset Auto Detection: BTC,SOL, etc]

497
DB - CME Gap [Multi Asset Auto Detection] is a pro-grade, zero-maintenance CME gap tracker designed for serious traders.

This script automatically detects unfilled CME futures gaps across a wide range of assets—crypto, equities, bonds, commodities, FX, and agriculture—by pulling the official Friday close from CME’s daily futures data. It visually highlights unfilled weekend gaps and keeps them active on the chart until the price fully crosses through the gap level, offering a reliable view of market inefficiencies that often attract future liquidity.

Whether you're trading BTC, ES, CL, ZN, 6E, or ZC... this tool auto-detects and adjusts to the asset you're charting, so you don’t need to change any settings.

🧠 Key Benefits
Fully Automated – No symbol selection required; works instantly across asset classes

Professional Grade – Clean, minimal visuals with dynamic gap tracking

Always Accurate – Uses CME official daily closes to identify true weekend gaps

Cross-Market Versatility – Supports a broad range of assets without editing code

✅ Features
🔍 Auto Symbol Detection
Automatically identifies whether you're viewing BTC, ETH, SOL, ES, NQ, CL, ZN, 6E, GC, ZC, and more—no input required.

📅 CME Friday Close Logic
Pulls the actual Friday close from CME's daily data to detect accurate gap reference points.

🚨 Weekend Gap Detection
Monitors Friday after-hours, Saturday, and Sunday to detect gaps between CME close and weekend price action.

🧠 Persistent Gap Tracking
Gaps remain active until price fully crosses the gap level—no false closures.

📈 Dynamic Line Drawing
Draws a horizontal line at the gap price and extends it to the point of fill.

🌈 Custom Gradient Shading
Fills the area between the current price and the CME gap with directional color gradients based on price movement.

🎨 User-Configurable Colors
Adjust bull and bear fill color themes to suit your personal style.

🧩 Compatible with All Major Asset Classes
Works with:

Crypto: BTC, ETH, SOL

Equities: ES, NQ, YM, MES, MNQ

Bonds & Rates: ZN, ZB, ZF, ZT, GE

Commodities: CL, GC, NG, BZ, SI

FX: 6E, 6J, 6B

Ags: ZC (Corn), ZS (Soybeans)
Note di rilascio
DB - CME Gap Indicator: Update Overview

We're excited to release this enhanced version of the DB - CME Gap indicator! Built on Pine Script v5, this update brings a host of new features, improved detection logic, and user-friendly customizations to make gap trading more intuitive and reliable across multiple assets like BTC, ETH, SOL, and traditional markets (e.g., ES, NQ, gold, forex). The core functionality—auto-detecting CME futures symbols, identifying price gaps during market closures, and shading them with a dynamic gradient until filled—remains intact but has been significantly refined for better accuracy and flexibility.

Whether you're trading crypto weekends or monitoring gaps in stocks/futures during holidays, this indicator now adapts more intelligently to real-world market behaviors. Below, we'll break down the key new features and fixes/improvements from the original version.

New Features
  • Customizable Gap Expiration (Max Gap Age in Months): Gaps can now automatically expire after a user-defined number of months (default: 0 for unlimited). This prevents old, irrelevant gaps from cluttering your chart—perfect for long-term analysis without manual cleanup. Set it via the new input (0-12 months).
  • Include Weekdays Option: Expand gap detection beyond weekends! Toggle this to include weekday closures (e.g., holidays or unexpected halts) when the CME market is inactive. This makes the indicator more versatile for non-crypto assets or irregular trading sessions.
  • Minimum Gap Size Filter: Ignore tiny, insignificant gaps with a minimum size threshold (default: 0 for all gaps). This helps focus on meaningful moves—e.g., filter out $1 gaps on BTC while capturing larger ones on SOL. Input is a float value for precision.
  • Gap Start Markers with Triangles and Size Labels: Visually highlight the exact start of each gap!
    Triangles: An upward green triangle for gap-ups (bullish) below the bar, or a downward red triangle for gap-downs (bearish) above the bar.
    Gap Size Text: Displays "$X Gap" (e.g., "$500 Gap") next to the triangle, showing the absolute gap size in dollars.
    Both are toggleable via new inputs ("Show Gap Triangles" and "Show Gap Size Text"). When both are enabled, the text appears neatly below the triangle for a clean, informative look.
  • Settings Configuration Table: A handy on-chart table in the top-right corner displays your current settings at a glance:
    Pine Script®
    Include Week Days | Yes/No Minimum Gap Size | X (your value)

    This quick-reference tool helps you verify configurations without opening the settings menu—great for troubleshooting or sharing charts.


These additions empower you to tailor the indicator to your strategy, whether you're a scalper filtering noise or a swing trader monitoring aged gaps.

Fixes and Improvements
  • Enhanced Market Closure Detection: The original relied on hardcoded weekend checks (Friday close to Monday open), which could miss holidays or fail during non-standard closures. Now, it dynamically detects closures using "unchanged bars" in the CME daily close (if unchanged for >=2 bars, assume closed). This fixes inaccurate gap triggers and broadens support for all assets, including newer ones like SOL (note: SOL CME data starts from March 2025, so historical gaps pre-launch won’t appear—see our tips on avoiding common issues).
  • More Robust Gap Start/Close Logic:
    Gaps now require a minimum size (fixing the original’s tendency to flag every tiny discrepancy as a gap).
    Tracks gap start time for expiration, ensuring lines don’t extend indefinitely.
  • Gradient Shading Refinements: The fill color logic has been updated to use the actual gap open price (CME close), improving visual accuracy during active gaps.
  • Asset Compatibility Tweaks: Multi-asset auto-detection (BTC, SOL, ETH, etc.) is more reliable, with fallback to ES1! for unmapped symbols. We’ve addressed potential issues with perpetuals or suffixes (e.g., “SOLUSDT.P” now correctly maps).


Overall, these changes make the indicator more accurate, customizable, and user-friendly while preserving its lightweight overlay design. If you’re updating from the original, you’ll notice smoother performance on recent data and better handling of edge cases like small gaps or extended closures.

Pro Tip: For assets like SOL with limited historical CME data, set a low Minimum Gap Size and enable Weekdays for optimal results. If gaps aren’t showing, check the config table or toggle debug options (coming in future updates? Let us know what you’d like!).

Thanks for using DB - CME Gap—happy trading! 🚀
Note di rilascio
minor update to comments...
Note di rilascio
Updating to make 3 months the default to the "Max Gap Age"

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.