OPEN-SOURCE SCRIPT

Dynamic Spot vs Perp Spread

### **Description for TradingView Publication**

---

**Dynamic Spot vs Perp Spread**
(For USDT-Spot and USDT.P-Perp)
Summary of Usefulness:
This indicator is a valuable tool for traders who want to monitor and capitalize on the relationship between spot and perpetual futures (perp) prices. When the spot price exceeds the perp price, it's often a leading signal that the perp price will follow, creating potential trading opportunities. While this behavior doesn't happen every time, divergences between spot and perp prices can frequently signal significant market movements.

What it Does:
This indicator calculates and displays the price spread (percentage difference) between the spot price and perpetual futures (perp) price of a cryptocurrency asset. It dynamically adjusts to the instrument being viewed, ensuring that spot dominance (spot price higher) is plotted above the zero line and perp dominance (perp price higher) is plotted below the zero line. Additionally, the indicator accounts for symbols with multipliers (e.g., `1000SHIBUSDT.P`) to ensure accurate calculations.

Key features include:
- Automatic symbol detection and adjustment for Spot/Perp pairs.
- Dynamic handling of price multipliers for assets with prefixes like `1000`.
- Visualization of spread with a histogram and optional smoothing using an EMA (Exponential Moving Average).
- Configurable alerts for significant spread changes and spread flips.
- No repainting: the indicator uses the `barmerge.lookahead_off` setting to ensure stable, non-repainting values.

---

### **How to Use**

1. **Add the Indicator:**
- Search for "Dynamic Spot vs Perp Spread" in the TradingView Indicators library and add it to your chart.

2. **Understand the Visualization:**
- A positive spread (green histogram) indicates that the spot price is higher than the perp price (spot dominance).
- A negative spread (red histogram) indicates that the perp price is higher than the spot price (perp dominance).

3. **Customize Settings:**
- **EMA Length:** Use the input field to smooth the spread data over a chosen number of periods.
- **Alert Threshold:** Set a threshold to receive alerts when the spread exceeds a specific percentage.

4. **Receive Alerts:**
- Enable alerts for spread flips (when dominance shifts between spot and perp) or when the spread exceeds the defined threshold.

5. **Use Case Examples:**
- **Spot vs. Perp Arbitrage:** Traders can monitor significant deviations between spot and perp prices to identify potential arbitrage opportunities.
- **Market Sentiment Analysis:** Persistent spot dominance may indicate stronger buying interest in the spot market, while perp dominance may suggest futures market speculation.

---

### **Repainting Behavior**

This indicator **does not repaint** because it uses `barmerge.lookahead_off` for all calculations, ensuring that data from the comparison symbol (spot or perp) is locked to the currently completed candle. This means the values plotted and alerts triggered are reliable and do not change retrospectively.

Repainting occurs when an indicator uses future-looking or incomplete data for calculations. By design, this indicator avoids such practices, making it suitable for live trading and analysis.

---
multitimeframesentimentTrend Analysis

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?


또한 다음에서도:

면책사항