OPEN-SOURCE SCRIPT
Bitcoin vs. S&P 500 Performance Comparison

**Full Description:**
**Overview**
This indicator provides an intuitive visual comparison of Bitcoin's performance versus the S&P 500 by shading the chart background based on relative strength over a rolling lookback period.
**How It Works**
- Calculates percentage returns for both Bitcoin and the S&P 500 (ES1! futures) over a specified lookback period (default: 75 bars)
- Compares the returns and shades the background accordingly:
- **Green/Teal Background**: Bitcoin is outperforming the S&P 500
- **Red/Maroon Background**: S&P 500 is outperforming Bitcoin
- Displays a real-time performance difference label showing the exact percentage spread
**Key Features**
✓ Rolling performance comparison using customizable lookback period (default 75 bars)
✓ Clean visual representation with adjustable transparency
✓ Works on any timeframe (optimized for daily charts)
✓ Real-time performance differential display
✓ Uses ES1! (E-mini S&P 500 continuous futures) for accurate comparison
✓ Fine-tuning adjustment factor for precise calibration
**Use Cases**
- Identify market regimes where Bitcoin outperforms or underperforms traditional equities
- Spot trend changes in relative performance
- Assess risk-on vs risk-off periods
- Compare Bitcoin's momentum against broader market conditions
- Time entries/exits based on relative strength shifts
**Settings**
- **S&P 500 Symbol**: Default ES1! (can be changed to SPX or other indices)
- **Lookback Period**: Number of bars for performance calculation (default: 75)
- **Adjustment Factor**: Fine-tune calibration to match specific data feeds
- **Transparency Controls**: Customize background shading intensity
- **Show/Hide Label**: Toggle performance difference display
**Best Practices**
- Use on daily timeframe for swing trading and position analysis
- Combine with other momentum indicators for confirmation
- Watch for color transitions as potential regime change signals
- Consider using multiple timeframes for comprehensive analysis
**Technical Details**
The indicator calculates rolling percentage returns using the formula: ((Current Price / Price[Lookback]) - 1) × 100, then compares Bitcoin's return to the S&P 500's return over the same period. The background color dynamically updates based on which asset is showing stronger performance.
**Overview**
This indicator provides an intuitive visual comparison of Bitcoin's performance versus the S&P 500 by shading the chart background based on relative strength over a rolling lookback period.
**How It Works**
- Calculates percentage returns for both Bitcoin and the S&P 500 (ES1! futures) over a specified lookback period (default: 75 bars)
- Compares the returns and shades the background accordingly:
- **Green/Teal Background**: Bitcoin is outperforming the S&P 500
- **Red/Maroon Background**: S&P 500 is outperforming Bitcoin
- Displays a real-time performance difference label showing the exact percentage spread
**Key Features**
✓ Rolling performance comparison using customizable lookback period (default 75 bars)
✓ Clean visual representation with adjustable transparency
✓ Works on any timeframe (optimized for daily charts)
✓ Real-time performance differential display
✓ Uses ES1! (E-mini S&P 500 continuous futures) for accurate comparison
✓ Fine-tuning adjustment factor for precise calibration
**Use Cases**
- Identify market regimes where Bitcoin outperforms or underperforms traditional equities
- Spot trend changes in relative performance
- Assess risk-on vs risk-off periods
- Compare Bitcoin's momentum against broader market conditions
- Time entries/exits based on relative strength shifts
**Settings**
- **S&P 500 Symbol**: Default ES1! (can be changed to SPX or other indices)
- **Lookback Period**: Number of bars for performance calculation (default: 75)
- **Adjustment Factor**: Fine-tune calibration to match specific data feeds
- **Transparency Controls**: Customize background shading intensity
- **Show/Hide Label**: Toggle performance difference display
**Best Practices**
- Use on daily timeframe for swing trading and position analysis
- Combine with other momentum indicators for confirmation
- Watch for color transitions as potential regime change signals
- Consider using multiple timeframes for comprehensive analysis
**Technical Details**
The indicator calculates rolling percentage returns using the formula: ((Current Price / Price[Lookback]) - 1) × 100, then compares Bitcoin's return to the S&P 500's return over the same period. The background color dynamically updates based on which asset is showing stronger performance.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
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.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
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.