OPEN-SOURCE SCRIPT
Cập nhật Spot Premium with ROC

Description:
This indicator tracks the spot premium of BTC by comparing the perpetual futures price (perp) from Binance against the spot price on Coinbase. The histogram displays the price difference (spot minus perp) with green bars when spot is higher and red when perp carries a premium. The Rate of Change (ROC) line measures how quickly this premium shifts, with an option to normalize fluctuations for greater stability.
Implications & Possible Use Cases:
Let me know if you would like additional features.
This indicator tracks the spot premium of BTC by comparing the perpetual futures price (perp) from Binance against the spot price on Coinbase. The histogram displays the price difference (spot minus perp) with green bars when spot is higher and red when perp carries a premium. The Rate of Change (ROC) line measures how quickly this premium shifts, with an option to normalize fluctuations for greater stability.
Implications & Possible Use Cases:
- • Market Sentiment Gauge: A sustained positive premium often indicates bullish sentiment, while a discount can signal bearish bias.
- • Arbitrage Signals: Significant divergences between perp and spot may present short-term arbitrage opportunities across exchanges.
- • Risk Management & Hedging: Traders can align derivatives and spot positions when premiums deviate sharply, reducing funding cost exposures.
- • Funding Rate Insights: Since perp funding rates tend to follow premium levels, this indicator can act as an early warning for funding spikes.
- • Trend Confirmation: Use the normalized ROC to confirm continuation or reversal of premium trends, filtering out noise around small diff values.
Let me know if you would like additional features.
Phát hành các Ghi chú
Description:This indicator tracks the spot premium of BTC by comparing the perpetual futures price (perp) from Binance against the spot price on Coinbase. The histogram displays the price difference (spot minus perp) with green bars when spot is higher and red when perp carries a premium. The Rate of Change (ROC) line measures how quickly this premium shifts, with an option to normalize fluctuations for greater stability.
Implications & Possible Use Cases:
- • Market Sentiment Gauge: A sustained positive premium often indicates bullish sentiment, while a discount can signal bearish bias.
- • Arbitrage Signals: Significant divergences between perp and spot may present short-term arbitrage opportunities across exchanges.
- • Risk Management & Hedging: Traders can align derivatives and spot positions when premiums deviate sharply, reducing funding cost exposures.
- • Funding Rate Insights: Since perp funding rates tend to follow premium levels, this indicator can act as an early warning for funding spikes.
- • Trend Confirmation: Use the normalized ROC to confirm continuation or reversal of premium trends, filtering out noise around small diff values.
Phát hành các Ghi chú
Description:This indicator tracks the spot premium of BTC by comparing the perpetual futures price (perp) from Binance against the spot price on Coinbase. The histogram displays the price difference (spot minus perp) with green bars when spot is higher and red when perp carries a premium. The Rate of Change (ROC) line measures how quickly this premium shifts, with an option to normalize fluctuations for greater stability.
Implications & Possible Use Cases:
- • Market Sentiment Gauge: A sustained positive premium often indicates bullish sentiment, while a discount can signal bearish bias.
- • Arbitrage Signals: Significant divergences between perp and spot may present short-term arbitrage opportunities across exchanges.
- • Risk Management & Hedging: Traders can align derivatives and spot positions when premiums deviate sharply, reducing funding cost exposures.
- • Funding Rate Insights: Since perp funding rates tend to follow premium levels, this indicator can act as an early warning for funding spikes.
- • Trend Confirmation: Use the normalized ROC to confirm continuation or reversal of premium trends, filtering out noise around small diff values.
Phát hành các Ghi chú
Mode: - “Auto” uses the chart’s symbol with chosen exchange prefixes; “Manual” lets you input full symbol codes.
- Spot Exchange: exchange prefix for spot (e.g., “COINBASE”)
- Derivatives Exchange: ex
Phát hành các Ghi chú
Added tooltipsPhát hành các Ghi chú
- Volume Intensity: histogram bars adjust opacity based on volume relative to its SMA over a lookback period.
Phát hành các Ghi chú
Fix to the Auto modePhát hành các Ghi chú
added ribbons for the ROCPhát hành các Ghi chú
Update Summary — Spot/Perp Premium + Basis (Vol-Weighted)Core upgrade
• Added the “tri-calculation” basis:
Tri-Calc = (CB–BIN Spot) − (CB–BIN Perp) = BIN Perp − BIN Spot
→ isolates Binance perp premium vs. Binance spot (local leverage sentiment).
• Keeps your prior two spreads for context:
1) CB Spot − BIN Spot (inter-venue spot flow)
2) CB Spot − BIN Perp (cross-venue spot vs. perp)
Display & defaults
• Toggles: Show CB−BIN Spot (ON), Show CB−BIN Perp (OFF), Show Tri-Calc (ON).
• Tri-Calc style: Line (default) or Histogram, with a “Tri-Calc Visual Scale” multiplier.
• Tri EMA line: always available via “Always Show Tri EMA (Line)”; color-coded by sign:
>0 → #00FFBD (teal), <0 → #E600FF (magenta). Honors optional −1 offset.
Symbol handling
• Auto/Manual symbol mode with robust base-asset detection (suffix-aware strip of .P/USDT/USDC/USD).
• Manual symbol overrides for CB spot, BIN spot, BIN perp.
Volume → histogram opacity
• Choose volume source: Spot / Deriv / Average.
• Mapping: SMA Ratio (squashed) or Percentile (more regime-stable), or Off.
• High volume = opaque bars; low volume = more transparent.
Momentum / impulse context (experimental overlays)
• Z-Score: shades when |Z| > threshold (mean/stdev).
• EMA+ROC: plots Tri EMA; background shades off MAD-normalized ROC of that EMA.
• Robust Z (MAD): outlier-resistant z-score flavor.
• RSI (of Tri): optional line plotted as (RSI−50)×scale for on-pane visibility; shade above/below bands.
• MACD (of Tri): optional MACD/Signal lines + histogram with a visual scale.
ROC ribbon (spread momentum)
• Short/long SMA of absolute changes on the first enabled series (spot-spot, else spot-perp, else tri).
• Filled ribbon flips color on short>long.
Reading the signals (quick cheat-sheet)
• CB Spot − BIN Spot rising while Tri-Calc (basis) depressed → spot-led accumulation, leverage risk-off:
Bias toward relief-up once perps re-engage (basis turns up).
• Basis ramping with CB premium flattening/falling → perp-led chase, prone to fade if spot demand isn’t present.
• RSI/MACD overlays on Tri help time the leverage “baton pass” (crosses/thresholds confirm rotation).
Good defaults to start
• Volume Lookback = 30, Volume Source = Spot, Mapping = Percentile.
• Z-Score: Lookback = 50, Threshold = 2.0.
• EMA+ROC: EMA = 9, ROC = 5, ROC threshold ≈ 1.0–1.5.
• RSI: Length = 14, Bands = 31 / 69, Visual Scale ≈ 0.5–1.0.
• MACD: 8/21/9 with Visual Scale ≈ 1.0–2.0.
Notes / pitfalls
• Pine arg ordering: once you use named args in plot(), name them all — start with series=...
• If overlays seem “invisible,” raise the RSI/MACD visual scale knobs to fit the pane amplitude.
• Tri EMA color is sign-based; Tri-Calc line/hist colors remain as configured.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.