OPEN-SOURCE SCRIPT
已更新 Bitcoin CME GAP [SAKANE]

This indicator detects and visualizes the weekend gap in CME Bitcoin futures (BTC1!), defined as the difference between the Friday settlement price and the Monday opening price. It stores the final CME close, waits for trading to resume, and then measures the gap. If the gap exceeds the user-defined threshold, it is displayed as a box on the chart. The box remains active until price returns to the gap’s closing level or a specified number of bars has elapsed. During the CME weekend closure, a horizontal reference line marks where CME last settled, providing a clear anchor for price positioning.
A key feature is that the gap is displayed correctly even on spot or perpetual BTC charts. Because futures prices often trade at a premium or discount relative to spot markets, plotting CME levels directly would misplace the gap. This script calculates the price difference between CME and the chart instrument and shifts the gap vertically into the chart’s price space while preserving its true size. As a result, traders can see the actual gap location where market participants are likely to react, without distortion from futures basis differences.
Gap-fill detection is performed using CME futures prices themselves. The script evaluates whether the CME high or low has reached the prior CME close level that defines the gap. This ensures that once the gap is filled in the futures market, it is considered filled everywhere. Because of this CME-based validation combined with spot-space visualization, users can determine whether a gap has closed without switching to the BTC1! chart.
CME gaps are widely observed by market participants because price frequently revisits and fills these discontinuities. By highlighting both the location and the fill status of the gap, this indicator helps track the gap-closure tendency and provides insight into short-term liquidity imbalances, derivatives-driven dislocations, and the market’s process of price repair.
A key feature is that the gap is displayed correctly even on spot or perpetual BTC charts. Because futures prices often trade at a premium or discount relative to spot markets, plotting CME levels directly would misplace the gap. This script calculates the price difference between CME and the chart instrument and shifts the gap vertically into the chart’s price space while preserving its true size. As a result, traders can see the actual gap location where market participants are likely to react, without distortion from futures basis differences.
Gap-fill detection is performed using CME futures prices themselves. The script evaluates whether the CME high or low has reached the prior CME close level that defines the gap. This ensures that once the gap is filled in the futures market, it is considered filled everywhere. Because of this CME-based validation combined with spot-space visualization, users can determine whether a gap has closed without switching to the BTC1! chart.
CME gaps are widely observed by market participants because price frequently revisits and fills these discontinuities. By highlighting both the location and the fill status of the gap, this indicator helps track the gap-closure tendency and provides insight into short-term liquidity imbalances, derivatives-driven dislocations, and the market’s process of price repair.
版本注释
The adjustPremium option has been added to control how the gap is positioned on the chart.When adjustPremium is OFF, the gap is drawn using raw CME futures prices. The box is plotted directly between the BTC1! Friday close (g_prev) and Monday open (g_open). Because no adjustment is applied, the gap reflects CME’s absolute price levels, including any futures premium or discount relative to spot markets.
When adjustPremium is ON, the gap is aligned to the chart’s price space. The Friday side is anchored to the chart’s closing price at the same moment as the CME Friday close (last_chart_close), while the Monday side uses the chart’s opening price on the CME reopen bar (open). In practice, this aligns the gap with the price levels of the instrument being viewed (e.g., Binance spot or perpetual), making it easier to see where the gap-equivalent discontinuity exists in the spot market.
Importantly, gap-fill detection continues to be evaluated strictly using CME futures prices (cme_high_off / cme_low_off). Even when the gap is visually aligned to the chart’s price space, fill status remains CME-native and consistent. This allows users to determine whether the CME gap has been filled without switching to the BTC1! chart.
版本注释
Fixed an issue where the indicator would fail to display on certain symbols and timeframes.开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。