RSI divergence: how it works and how to test it
By Oalgo · Last reviewed
RSI divergence is when price and RSI disagree about a swing. Price makes a lower low but RSI makes a higher low, or price makes a higher high but RSI makes a lower high. People read it as a move that is losing strength. It compares two swings, so it is not a level of RSI like 30 or 70.
How do you find an RSI divergence?
#- Find two swing lows of RSI, and read the price at the same candles. A swing low is the lowest point with a set number of candles on each side, for example 5.
- Keep the two swings close enough to belong together, for example 5 to 60 candles apart. The limit is your choice.
- Regular bullish divergence: the price at the second low is lower than at the first, and RSI at the second low is higher.
- Regular bearish divergence: the price at the second high is higher than at the first, and RSI at the second high is lower.
- Hidden divergence is the other way round. The regular vs hidden divergence page sets the four cases side by side.
What does a worked example look like?
#| Swing | Price low | RSI at that low | Compared with the first low |
|---|---|---|---|
| First low | 100 | 24 | – |
| Second low | 98 | 31 | Price is 2% lower, RSI is 7 points higher |
| Result | – | – | Regular bullish divergence |
The chart shows the same thing on the example prices. RSI at the first low is 26.0 and at the second 33.7, while the price at those candles goes from 88.96 to 88.72. The price difference is small, so a rule has to decide whether a lower low of any size counts.
Why is a divergence found late?
#A swing low only counts once the candles after it have closed. With 5 candles on each side, the second low in the chart is confirmed 5 candles after it happened. In the example prices the close was 90.62 at that low and 95.55 five candles later, 5.4% higher. A test that read the divergence at the low itself would use prices from the future, which is lookahead bias.
What are the rules of an RSI divergence strategy?
#- Entry: a regular bullish divergence is confirmed, for example on RSI over 14 candles with swings of 5 candles on each side.
- Exit: RSI rises above 50, or a set number of candles have passed since the entry (the Time Exit setting).
- Stop: a Stop Loss as a percentage, because a divergence can be followed by a further fall.
How do you write this strategy in Oalgo?
#In Oalgo you can tell Oalgo AI your RSI divergence rule in your own words, check the rule it builds, and test it. After testing, if you choose, you Go Live with your own Live Strategy on your own Venue Account at a Supported Venue.
The builder has no divergence block. Oalgo AI builds the divergence as an indicator first, one that marks the candles where a divergence is confirmed, and you check it on the chart. You then ask for the entry and exit that use it. For example, you could tell Oalgo AI: "Build an indicator that marks a regular bullish divergence of RSI (14), with swings of 5 candles on each side and 5 to 60 candles between the two lows." Then: "Enter when it marks a divergence. Exit when RSI rises above 50. Use a 2% Stop Loss and a 4% exit target." These numbers are examples to change. A Live Strategy needs a stop on each side it can enter, and an exit target is optional. The example names both.
A simpler rule can be made from blocks alone. A Lookback block compares a value now with the same value some candles ago, so "the close is lower than 15 candles ago while RSI is higher than 15 candles ago" takes two of them. That compares two single candles, not two swings, so it is a different rule.
How do you test this strategy honestly?
#- Run a backtest on a falling period, a rising one and a sideways one. A divergence rule can behave very differently in each.
- Check the number of trades. Strict swing sizes find few divergences, and a few trades say little.
- Change the swing size, for example 3, 5 and 8 candles. If the report changes a lot, the first result may be fitted to one period.
- Run a forward test on new prices, with simulated funds.
What can RSI divergence not tell you?
#A divergence says that two swings disagree. It does not say price will turn. In a strong move RSI can show a divergence again and again while price keeps going, and each one is an entry that came too early. The result also depends on how a swing is defined: with 3 candles on each side there are many divergences, with 10 only a few. Two people can mark different divergences on the same chart, which is why a rule needs fixed numbers for the size of a swing and the distance between two of them.
Read next
- What is RSI? The RSI indicator explainedThe RSI indicator compares recent up moves with down moves on a scale from 0 to 100. Learn how it is calculated, how to read it, and how to test RSI rules.
- Regular vs hidden divergence: how they differRegular divergence is read as a move losing strength, hidden divergence as a trend continuing. See the four cases side by side and how to test them.