OPEN-SOURCE SCRIPT

RSI Divergence - Left Candles Only

rsi
The **RSI Divergence** indicator in this script is designed to highlight **divergence** between the **Relative Strength Index (RSI)** and **price action** on a chart. Divergence can be a key signal for potential trend reversals or continuation in technical analysis.

### **Key Components of the Indicator:**

1. **RSI Calculation:**
- The **Relative Strength Index (RSI)** is calculated using a typical 14-period length, but the user can customize this input.
- RSI is a momentum oscillator that measures the speed and change of price movements, oscillating between 0 and 100. Values above 70 indicate overbought conditions, and values below 30 indicate oversold conditions.

2. **Divergence Logic:**
- **Bullish Divergence:** Occurs when the price forms a **lower low**, but the RSI forms a **higher low**. This suggests that despite price continuing to drop, momentum (RSI) is strengthening, which may indicate a potential price reversal to the upside.
- **Bearish Divergence:** Occurs when the price forms a **higher high**, but the RSI forms a **lower high**. This indicates that even though price is rising, the momentum (RSI) is weakening, which could signal a price reversal to the downside.

3. **Pivot Identification:**
- The script identifies **pivot points** (local highs and lows) on both price and RSI.
- **Bullish Divergence:** A lower price low with a higher RSI low.
- **Bearish Divergence:** A higher price high with a lower RSI high.

4. **Lookback Periods:**
- **Lookback Left (lookbackLeft):** Defines the number of bars to look back for pivot confirmation. This allows for adjusting the sensitivity of the divergence.
- The **divergence range** is constrained by two parameters:
- **Minimum range (rangeLower):** The minimum number of bars for divergence to be considered.
- **Maximum range (rangeUpper):** The maximum number of bars for divergence to be considered.

5. **Signal Generation and Plotting:**
- When a **bullish divergence** is detected, a **green label** is plotted below the bar where the divergence occurs.
- When a **bearish divergence** is detected, a **red label** is plotted above the bar.
- The script uses **`plotshape()`** to plot these labels on the chart.

6. **Alerts:**
- Alerts are configured for both **bullish** and **bearish divergences** so that you can be notified when a divergence signal occurs.

---

### **How the Indicator Works:**
- The RSI and price action are compared using **pivots**: The script checks whether the price and RSI are forming new highs or lows within the specified **lookback period**.
- If the conditions for divergence (higher/lower RSI pivot vs price pivot) are met, a signal is plotted on the chart.
- The script helps to visually identify potential reversal points and allows users to set alerts for these divergence signals.

---

### **Use Case:**
- This script is useful for traders looking to trade potential trend reversals based on **divergence** between price and RSI.
- **Bullish divergence** can indicate a **buy** opportunity, while **bearish divergence** can suggest a **sell** opportunity.
- The indicator works best in **volatile markets** and when combined with other technical analysis tools for confirmatio
Relative Strength Index (RSI)

오픈 소스 스크립트

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

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

면책사항