Forex Indicator Reviews

TradingView Pine Script: RSI Divergence Indicator (Free Version)

When it comes to technical analysis, one of the most commonly used indicators is the Relative Strength Index (RSI), which measures the speed and change of price movements. Traders often use RSI to identify potential overbought or oversold conditions in a market. However, another powerful tool that many traders utilize alongside RSI is RSI Divergence, a technique that can provide insights into potential reversals or trend continuations.

In this article, we’ll explore how to create a RSI Divergence Indicator in Pine Script on TradingView and offer a free version for use.

What is RSI Divergence?

RSI Divergence occurs when the price of an asset forms new highs or lows that are not reflected by the RSI. Divergence can indicate a weakening trend, potentially signaling a reversal or the end of a current trend.

  • Bullish Divergence: This occurs when the price makes a lower low while the RSI makes a higher low, suggesting that the selling pressure is weakening and a reversal to the upside could occur.
  • Bearish Divergence: This happens when the price forms a higher high, but the RSI makes a lower high, suggesting that buying pressure is losing momentum and a reversal to the downside could occur.

How to Create an RSI Divergence Indicator Using Pine Script

TradingView’s Pine Script allows traders to automate and visualize custom indicators. Below is a simple and free Pine Script code that identifies RSI divergence and plots signals for potential trend reversals.

Pine Script for RSI Divergence

//@version=5
indicator("RSI Divergence", shorttitle="RSI Divergence", overlay=true)

// Input for RSI settings
rsiLength = input.int(14, title="RSI Length")
rsiSource = input.source(close, title="RSI Source")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")

// Calculate the RSI
rsi = ta.rsi(rsiSource, rsiLength)

// Function to detect Bullish Divergence
bullishDiv = ta.lowest(rsi, rsiLength) > ta.lowest(rsiSource, rsiLength)

// Function to detect Bearish Divergence
bearishDiv = ta.highest(rsi, rsiLength) < ta.highest(rsiSource, rsiLength)

// Plotting Divergence Signals on the Chart
plotshape(bullishDiv, title="Bullish Divergence", location=location.belowbar, color=color.green, style=shape.labelup, text="Bullish Div")
plotshape(bearishDiv, title="Bearish Divergence", location=location.abovebar, color=color.red, style=shape.labeldown, text="Bearish Div")

// Plotting the RSI for reference
plot(rsi, color=color.blue, title="RSI Line")
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)

Explanation of the Code:

  • RSI Calculation: The script calculates the RSI using the ta.rsi function with a customizable length and source (typically the close price).
  • Bullish and Bearish Divergence: The script uses ta.lowest and ta.highest functions to detect when price makes a new low or high, and compares it with the RSI’s corresponding low or high. If a divergence is detected, the script will generate an alert.
  • Plots: The code then plots the divergence signals as up or down arrows on the chart. Bullish divergence will appear below the bars in green, while bearish divergence will appear above the bars in red.
  • RSI Overlay: Finally, the RSI is plotted at the bottom of the chart, with overbought and oversold levels set at 70 and 30, respectively.

How to Use the RSI Divergence Indicator

  1. Identify Divergence:
    • Look for the divergence signals that appear as green or red arrows on the price chart.
    • Green Arrow: This suggests a potential bullish reversal, indicating that selling pressure is weakening.
    • Red Arrow: This indicates a potential bearish reversal, suggesting that buying pressure is weakening.
  2. Confirm with Other Indicators: While divergence can provide valuable insights, it is often best to confirm these signals with other technical indicators, such as moving averages, MACD, or support and resistance levels.
  3. Adjust RSI Settings: You can modify the RSI length and overbought/oversold levels to better fit the asset you are trading. For example, some traders prefer a shorter RSI period for more sensitive signals or adjust overbought/oversold levels based on asset volatility.

Benefits of Using RSI Divergence

  • Early Trend Reversal Signals: Divergence is often a leading indicator, allowing traders to spot potential reversals before they happen.
  • Versatility: RSI divergence can be applied to any market or time frame, making it a versatile tool for both day traders and long-term investors.
  • Risk Management: Detecting divergence can help traders avoid entering trades that might reverse, potentially reducing risk and improving trade timing.

Conclusion

Creating a RSI Divergence Indicator using Pine Script on TradingView can provide valuable insights into potential market reversals. The free version of the script shared above is easy to implement and can help you identify divergence in real time. While RSI divergence is a powerful tool, it’s always recommended to use it in combination with other technical analysis methods to improve your trading decisions.

Happy trading, and may your strategy lead to profitable trades!

AVA AIGPT5 EA: AI Gold Scalper for MT4

(2)

In stock

$0.00 $849.99Price range: $0.00 through $849.99
Select options This product has multiple variants. The options may be chosen on the product page

FXCore100 EA [UPDATED]

(3)

342 in stock

Original price was: $490.00.Current price is: $7.99.

Golden Deer Holy Grail Indicator (Lifetime Premium)

(12)

324 in stock

Original price was: $1,861.99.Current price is: $187.99.

Mythos Epic EA: AI Gold Scalper for MT5

(0)

In stock

$0.00 $849.99Price range: $0.00 through $849.99
Select options This product has multiple variants. The options may be chosen on the product page

Nexora Manus EA: AI Gold Scalper for MT5

(0)

In stock

$0.00 $849.99Price range: $0.00 through $849.99
Select options This product has multiple variants. The options may be chosen on the product page

Powerful Forex VPS for MT4 & MT5 – Best Price

(11)

182 in stock

$44.99 $359.99Price range: $44.99 through $359.99
Select options This product has multiple variants. The options may be chosen on the product page

Zenith Matrix EA: AI Gold Scalper for MT5

(0)

In stock

$0.00 $849.99Price range: $0.00 through $849.99
Select options This product has multiple variants. The options may be chosen on the product page
author-avatar

About Daniel B Crane

Hi there! I'm Daniel. I've been trading for over a decade and love sharing what I've learned. Whether it's tech or trading, I'm always eager to dive into something new. Want to learn how to trade like a pro? I've created a ton of free resources on my website, bestmt4ea.com. From understanding basic concepts like support and resistance to diving into advanced strategies using AI, I've got you covered. I believe anyone can learn to trade successfully. Join me on this journey and let's grow your finances together!

Leave a Reply