OPEN-SOURCE SCRIPT
Scam detector

Spot–Perpetual Divergence (SPD)
Spot–Perpetual Divergence is a professional market-structure indicator designed to reveal when the spot and perpetual futures markets stop moving together.
Instead of looking only at the perpetual premium, this indicator compares the actual price behaviour of both markets and highlights situations where one side becomes significantly stronger or weaker than the other.
It automatically detects whether your chart is a spot or perpetual market and compares it with the matching counterpart using the same timeframe. The calculations remain identical regardless of which chart you are viewing.
Features
• Automatic Spot ↔ Perpetual detection
• Bidirectional operation (same signals on Spot or Perpetual charts)
• Automatic chart timeframe detection
• Automatic TradingView ".P" pairing (manual pairing also supported)
• Configurable divergence threshold (default 0.50%)
• Oscillator and candle-chart signals
• Signal tooltips and alert conditions
• Live information table
Detection Engines
The indicator combines multiple divergence methods:
Cumulative Return Divergence
Compares the total percentage return of Spot and Perpetual over the selected event window.
Downside Excursion Divergence
Detects when one market experiences a significantly deeper sell-off than the other.
Upside Excursion Divergence
Detects when one market rallies significantly more than the other.
Single-Bar Wick Divergence
Finds unusually large wick differences that may indicate aggressive buying or selling pressure.
Perpetual Premium / Discount
Measures the direct price difference between Perpetual and Spot.
Signal Guide
SD — Spot Dropped More
Spot experienced a deeper decline than Perpetual futures.
PD — Perpetual Dropped More
Perpetual futures experienced a deeper decline than Spot.
SC — Spot Cumulative Underperformance
Spot underperformed Perpetual over the selected event window.
PC — Perpetual Cumulative Underperformance
Perpetual underperformed Spot over the selected event window.
PU — Perpetual Rose More
Perpetual futures rallied more than Spot.
SU — Spot Rose More
Spot rallied more than Perpetual futures.
SW — Spot Wick Deeper
Spot printed a significantly deeper downside wick.
PW — Perpetual Wick Deeper
Perpetual futures printed a significantly deeper downside wick.
How It Can Be Used
Spot–Perpetual divergences often appear during periods of:
Panic selling
Leveraged liquidations
Short squeezes
Long squeezes
Futures overreaction
Spot-led accumulation
Perpetual-led speculation
Large divergences can signal that one market is reacting much more aggressively than the other, which may precede convergence or further directional moves. They should be interpreted alongside price action, liquidity, volume, and overall market structure rather than as standalone buy or sell signals.
Notes
Works on any asset that has both Spot and Perpetual markets.
Supports automatic and manual market pairing.
The default divergence threshold is 0.50%, but it can be adjusted to suit different assets and trading styles.
Designed for crypto markets but can be adapted to any market with equivalent Spot and Futures instruments.
Spot–Perpetual Divergence is a professional market-structure indicator designed to reveal when the spot and perpetual futures markets stop moving together.
Instead of looking only at the perpetual premium, this indicator compares the actual price behaviour of both markets and highlights situations where one side becomes significantly stronger or weaker than the other.
It automatically detects whether your chart is a spot or perpetual market and compares it with the matching counterpart using the same timeframe. The calculations remain identical regardless of which chart you are viewing.
Features
• Automatic Spot ↔ Perpetual detection
• Bidirectional operation (same signals on Spot or Perpetual charts)
• Automatic chart timeframe detection
• Automatic TradingView ".P" pairing (manual pairing also supported)
• Configurable divergence threshold (default 0.50%)
• Oscillator and candle-chart signals
• Signal tooltips and alert conditions
• Live information table
Detection Engines
The indicator combines multiple divergence methods:
Cumulative Return Divergence
Compares the total percentage return of Spot and Perpetual over the selected event window.
Downside Excursion Divergence
Detects when one market experiences a significantly deeper sell-off than the other.
Upside Excursion Divergence
Detects when one market rallies significantly more than the other.
Single-Bar Wick Divergence
Finds unusually large wick differences that may indicate aggressive buying or selling pressure.
Perpetual Premium / Discount
Measures the direct price difference between Perpetual and Spot.
Signal Guide
SD — Spot Dropped More
Spot experienced a deeper decline than Perpetual futures.
PD — Perpetual Dropped More
Perpetual futures experienced a deeper decline than Spot.
SC — Spot Cumulative Underperformance
Spot underperformed Perpetual over the selected event window.
PC — Perpetual Cumulative Underperformance
Perpetual underperformed Spot over the selected event window.
PU — Perpetual Rose More
Perpetual futures rallied more than Spot.
SU — Spot Rose More
Spot rallied more than Perpetual futures.
SW — Spot Wick Deeper
Spot printed a significantly deeper downside wick.
PW — Perpetual Wick Deeper
Perpetual futures printed a significantly deeper downside wick.
How It Can Be Used
Spot–Perpetual divergences often appear during periods of:
Panic selling
Leveraged liquidations
Short squeezes
Long squeezes
Futures overreaction
Spot-led accumulation
Perpetual-led speculation
Large divergences can signal that one market is reacting much more aggressively than the other, which may precede convergence or further directional moves. They should be interpreted alongside price action, liquidity, volume, and overall market structure rather than as standalone buy or sell signals.
Notes
Works on any asset that has both Spot and Perpetual markets.
Supports automatic and manual market pairing.
The default divergence threshold is 0.50%, but it can be adjusted to suit different assets and trading styles.
Designed for crypto markets but can be adapted to any market with equivalent Spot and Futures instruments.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。