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
Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.