Relative Strength Index
Yaser Rahmati | یاسر رحمتی
Last updated
Yaser Rahmati | یاسر رحمتی
Last updated
The Relative Strength Index (RSI) is a popular momentum oscillator used in technical analysis to measure the speed and change of price movements. It was developed by J. Welles Wilder and is used to identify overbought or oversold conditions in a market.
Calculation:
RSI is calculated using the following formula:
Where RS (Relative Strength) is the average of 'n' days' up closes divided by the average of 'n' days' down closes.
RSI values range from 0 to 100.
Overbought Condition: RSI above 70 suggests that the asset might be overbought and could be due for a pullback.
Oversold Condition: RSI below 30 suggests that the asset might be oversold and could be due for a rebound.
Assume the following closing prices for 15 days:
1
44
2
45
+1
1
0
3
46
+1
1
0
4
44
-2
0
2
5
44
0
0
0
6
46
+2
2
0
7
48
+2
2
0
8
47
-1
0
1
9
49
+2
2
0
10
50
+1
1
0
11
48
-2
0
2
12
47
-1
0
1
13
46
-1
0
1
14
48
+2
2
0
15
49
+1
1
0
Calculate the average gain and average loss for the first 14 days:
Total Gain
Total Loss
Average Gain
Average Loss
Calculate the Relative Strength (RS)
Calculate the RSI
Buy Signal: When RSI crosses above the 30 level, indicating a potential rebound from oversold conditions.
Sell Signal: When RSI crosses below the 70 level, indicating a potential pullback from overbought conditions.
Bullish Divergence: Occurs when the price makes a new low but RSI makes a higher low. This can signal a potential upward reversal.
Bearish Divergence: Occurs when the price makes a new high but RSI makes a lower high. This can signal a potential downward reversal.
Bullish Swing Rejection: RSI moves below 30, rebounds above 30, then pulls back but stays above 30, and finally moves higher. This pattern can signal a potential buying opportunity.
Bearish Swing Rejection: RSI moves above 70, pulls back below 70, rebounds but stays below 70, and finally moves lower. This pattern can signal a potential selling opportunity.
Bullish Signal: RSI crosses above the 50 level, indicating potential upward momentum.
Bearish Signal: RSI crosses below the 50 level, indicating potential downward momentum.
Here's a basic Pine Script code to plot RSI on TradingView:
//@version=5
: This line specifies that the script uses Pine Script version 5.
indicator("Relative Strength Index (RSI)", overlay=false)
: This line declares an indicator named "Relative Strength Index (RSI)". The overlay=false
parameter means the RSI will be plotted in a separate pane below the price chart, not overlaid on the price chart.
rsiPeriod = input.int(14, title="RSI Period", minval=1)
: This line creates an input field for the user to specify the period for the RSI calculation. The default value is set to 14, and the minimum allowable value is 1.
rsiValue = ta.rsi(close, rsiPeriod)
: This line calculates the RSI value using the built-in ta.rsi
function, which takes the closing prices and the specified period as arguments.
plot(rsiValue, title="RSI", color=color.blue)
: This line plots the calculated RSI values on the chart with the title "RSI" and in blue color.
hline(70, "Overbought", color=color.red)
: This line draws a horizontal line at the 70 level, marking the overbought threshold in red.
hline(30, "Oversold", color=color.green)
: This line draws a horizontal line at the 30 level, marking the oversold threshold in green.
bgcolor(rsiValue > 70 ? color.new(color.red, 90) : na, title="Overbought Background")
: This line changes the background color to a semi-transparent red (90% opacity) when the RSI value is above 70, indicating an overbought condition. If the RSI is not above 70, it does nothing (na
).
bgcolor(rsiValue < 30 ? color.new(color.green, 90) : na, title="Oversold Background")
: This line changes the background color to a semi-transparent green (90% opacity) when the RSI value is below 30, indicating an oversold condition. If the RSI is not below 30, it does nothing (na
).
Relative Strength Index
, RSI
, Momentum Oscillator
, Technical Analysis
, Overbought
, Oversold
, Trading Indicator
, RSI Divergence
, RSI Calculation
, RSI Strategy
, Price Momentum
, Trend Reversal
, Trading Signals
, Financial Markets
, RSI Period
, یاسر رحمتی