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
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Để truy cập nhanh vào biểu đồ, hãy thêm tập lệnh này vào mục yêu thích của bạn — tìm hiểu thêm tại đây.
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Để truy cập nhanh vào biểu đồ, hãy thêm tập lệnh này vào mục yêu thích của bạn — tìm hiểu thêm tại đây.
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.