RSI (Relative Strength Index)
Has the price run up or down too far, too fast?
A 0 to 100 gauge that compares the size of recent up days with recent down days.
RSI on a chart of past prices
Settings: move a slider and the chart redraws
How many days of moves are averaged. 14 is the standard.
Above this, the rule calls the run-up stretched.
Below this, the rule calls the fall stretched.
What it measures
RSI compares the average gain on up days with the average loss on down days over the last 14 days. If the gains have been much bigger it is near 100; if the losses have, near 0; if they balance, around 50.
The averages are smoothed the way J. Welles Wilder, who invented RSI, did it: each day the new average is 13 parts yesterday's average and 1 part today's move. So one big day nudges RSI rather than jolting it.
Above 70 is often called “overbought” (the price has risen a lot, quickly) and below 30 “oversold”. Those words describe the past, not the future.
How traders read it
- Above 70: a strong run up. Below 30: a strong run down. In between: no extreme.
- The classic rule waits for RSI to climb back above 30 (the selling has eased) to buy, and to drop back below 70 to sell. Marked on the chart.
- 50 is the dividing line: RSI holding above 50 means up days have outweighed down days.
- Divergence: the price makes a new low but RSI does not. Traders read that as selling losing force.
The traps
“Overbought” can stay “overbought”
In a strong uptrend RSI can sit above 70 for weeks while the price keeps climbing. Selling each time it crosses 70 means selling strong stocks early.
“Oversold” can get more “oversold”
A stock with bad news can stay below 30 and keep falling. A low RSI is not a floor.
The levels belong to the period
RSI 2 or RSI 5 hit the extremes all the time; RSI 30 almost never does. 30 and 70 were set for a 14-day RSI.
Test the classic rule: RSI reversal
Waiting for prices…
Quick check
Waiting for prices…
Use it in a script
function run(bars, ta, helpers) {
const rsi = ta.rsi(helpers.closes(bars), 14);
const signals = [];
for (let i = 1; i < bars.length; i++) {
if (rsi[i - 1] <= 30 && rsi[i] > 30) signals.push(helpers.buy(i)); // climbs back above 30
else if (rsi[i - 1] >= 70 && rsi[i] < 70) signals.push(helpers.sell(i)); // drops back below 70
}
return helpers.finalize(signals);
}This is the rule tested above, with the settings on your sliders, and it gives exactly the same buy and sell candles. Paste it into the Scripts drawer of the chart workbench, or save it and compare it across stocks in the Strategy Lab. New to scripts? The Writing strategies track starts from zero.
In the reference:ta.rsi