OPEN-SOURCE SCRIPT

Scam detector

416
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.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.