OPEN-SOURCE SCRIPT

Codi's Perp-Spot Basis

# Perp-Spot Basis Indicator

This indicator calculates the percentage basis between perpetual futures and spot prices for crypto assets. It is inspired by the original concept from **Krugermacro**, with the added improvement of **automatic detection of the asset pairs** based on the current chart symbol. This enhancement makes it faster and easier to apply across different assets without manual configuration.

## How It Works
The indicator compares the perpetual futures price (e.g., `BTCUSDT.P`) to the spot price (e.g., `BTCUSDT`) on Binance. The difference is expressed as a percentage: (Perp - Spot) / Spot * 100


The results are displayed in a color-coded graph:
- **Blue (Positive Basis):** Perpetual futures are trading at a premium, indicating **bullish sentiment** among derivatives traders.
- **Red (Negative Basis):** Perpetual futures are trading at a discount, indicating **bearish sentiment** among derivatives traders.

This percentage basis is a core component in understanding funding rates and derivatives market dynamics. It serves as a faster proxy for funding rates, which typically lag behind real-time price movements.

---

## How to Use It
### General Concept
- **Red (Negative Basis):** Ideal to execute **longs** when derivatives traders are overly bearish.
- **Blue (Positive Basis):** Ideal to execute **shorts** when derivatives traders are overly bullish.

### Pullback Sniping
1. During an **uptrend**:
- If the basis turns **red** temporarily, it can signal an opportunity to **buy the dip**.
2. During a **downtrend**:
- If the basis turns **blue** temporarily, it can signal an opportunity to **sell the rip**.
3. Wait for the basis to **pop back** (higher in uptrend, lower in downtrend) to time entries more effectively—this often coincides with **stop runs** or **liquidations**.

### Intraday Execution
- **When price is falling**:
- If the basis is **red**, the move is derivatives-led (**normal**).
- If the basis is **blue**, spot traders are leading, and perps are offside—wait for **price dumps** before longing.
- **When price is rising**:
- If the basis is **blue**, the move is derivatives-led (**normal**).
- If the basis is **red**, spot traders are leading, and perps are offside—wait for **price pops** before shorting.

### Larger Time Frames
- **Consistently Blue Basis:** Indicates a **bull market** as derivatives traders are bullish over the long term.
- **Consistently Red Basis:** Indicates a **bear market** as derivatives traders are bearish over the long term.

---

## Improvements Over the Original
This version of the Perp-Spot Basis indicator **automatically detects the Binance perpetual futures and spot pairs** based on the current chart symbol. For example:
- If you are viewing `ETHUSDT`, it automatically references `ETHUSDT.P` for the perpetual futures pair and `ETHUSDT` for the spot pair in BINANCE.
sentimentstatisticsTrend Analysis

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明