VALYNOX
VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Indicators and signals

RSI divergence: does it work? Rules, stops and an ES backtest

RSI divergence can only be judged after the swing points, the entry, the stop and the exit are written as rules and the trades are counted. A divergence drawn by eye after the move always looks right. On ES daily bars, a rule-based RSI reversal stand-in produced 137 trades in six and a half years, and the trade count is the first number to read.

By · Published · updated · Editorial policy

Contents
  1. Does RSI divergence work as a reversal signal?
  2. What are bullish, bearish and hidden RSI divergence?
  3. How do you detect swings without judging by eye?
  4. How do you place the order and set the stop?
  5. Which timeframe works better for RSI divergence?
  6. What does the ES futures backtest show, trade count included?
  7. Frequently asked questions
  8. References

Does RSI divergence work as a reversal signal?

RSI divergence works as a signal only after it is written as rules: how a swing is found, which two swings are compared, where the entry goes and where the stop sits. Drawn by eye after the move, every divergence looks right and none can be counted, and counting trades is the only way to tell a pattern from a story.

RSI divergence is a disagreement between the direction of two price swings and the direction of the RSI readings on the same two bars. The Relative Strength Index (RSI) is a momentum gauge from Wilder (1978) that runs between 0 and 100; the basics of its 14-period default and the 70/30 levels are covered in how to read and test RSI rules. Divergence watchers argue that when price pushes to a new low but RSI does not, the selling is losing force and a turn is near.

The trouble with that argument is not the idea but the way it is usually checked. A trader scrolls back through a chart, finds a bottom, and notices that RSI made a higher low there. The divergences that were followed by nothing stay invisible because nobody draws a swing on a flat stretch. It is like a weather forecaster who only writes down the forecasts that came true. To get a fair count, the pattern must become a chain of rules a computer can apply to every bar, which is the test any chart tool must pass before it belongs in a strategy; which technical analysis tools can be written as testable rules sorts the common ones by that standard.

Five written rules (swing, compare, entry, stop, exit) lead to counting the trades. A divergence found by eye after the move leads to nothing. Rules first, then count Five written rules, or no signal Swing Compare Entry Stop Exit Count By eye none By eye, failures are never drawn. So: write five rules, then count.
A divergence becomes testable only as a chain of written rules that ends in a trade count. A divergence found by eye after the move leads nowhere.

What are bullish, bearish and hidden RSI divergence?

Regular divergence is price making a new extreme while RSI does not, and it is read as a reversal signal; hidden divergence is RSI making a new extreme while price does not, and it is read as a continuation signal. Each of the four cases compares exactly two swing points on price with the RSI values on the same two bars, so the whole definition fits in a table.

TypePrice: second swing vs firstRSI: second swing vs firstRead asDirection
Regular bullish divergenceLower lowHigher lowReversalLong
Regular bearish divergenceHigher highLower highReversalShort
Hidden bullish divergenceHigher lowLower lowContinuation of an uptrendLong
Hidden bearish divergenceLower highHigher highContinuation of a downtrendShort
Four RSI divergence types compare two swings on price and on RSI: regular bullish and regular bearish read as reversal, hidden bullish and hidden bearish read as continuation Who makes the new extreme? Top line price, bottom line RSI Regular bullish Reversal Regular bearish Reversal Hidden bullish Continuation Hidden bearish Continuation
The four divergence types differ only in which line makes the new extreme. Regular divergence is traded against the price move, hidden divergence with it.

Bullish divergence in the regular form is the one most traders mean when they say "RSI divergence": price prints a lower low, RSI prints a higher low, and the trader looks for a long entry. Hidden divergence is the mirror image and is used by trend followers: in an uptrend, price pulls back to a higher low while RSI dips to a lower low, and the trader reads the deep RSI dip as a pullback inside a trend that has not ended. The two forms give opposite instructions on the same chart depending on which one you are looking for, which is one more reason to fix the definition before the test and not during it. A related trap is a strong trend that pins RSI above 70 for weeks; what an RSI stuck in the overbought zone means explains why a high reading alone is not a sell, and why a bearish divergence read during such a stretch needs the same strict swing rule as any other.

How do you detect swings without judging by eye?

A swing low is a bar whose low is below the lows of a set number of bars on each side of it, and a swing high is the same with highs; because the right-side bars must close first, the swing is confirmed only several bars after it happened, and that delay is part of the rule. Lo, Mamaysky and Wang (2000) took exactly this route for chart patterns: they wrote each pattern as a rule a computer could apply to every bar, and only then asked whether the pattern carried information. The same discipline applies here.

  1. Choose the swing strength N. A swing low needs N bars with higher lows on its left and N bars with higher lows on its right. Common values are 3 to 5. A larger N finds fewer, bigger swings.
  2. Confirm the swing N bars later. On the bar that closes N bars after the candidate low, check that all N right-side lows are higher. Only then does the swing exist for the strategy.
  3. Read RSI on the two swing bars. Take the RSI value on the bar of the first swing low and on the bar of the second. Compare price to price and RSI to RSI.
  4. Set a maximum distance between the two swings. For example, the second swing must fall within 60 bars of the first; two lows a year apart are not one pattern.
  5. Set a minimum RSI difference. For example, the second RSI low must be at least 2 points higher than the first, so that a difference of 0.1 does not count as divergence.
A swing low with five bars before and five bars after it: the swing is confirmed only when the fifth bar after the low has closed, and RSI is read for the low bar itself A swing shows up late Swing low with N = 5, daily bars RSI 34 5 before Low 5 after Confirmed 5 bars later The low is known 5 bars late. So: act only on the confirmed bar.
A pivot swing exists only after the right-side bars have closed. The strategy learns about the low five bars after it printed and reads RSI for that same bar.

Hypothetical example

Swing strength N = 5 on daily bars. The first swing low prints on a Monday at 4,000 points with RSI at 28. Twenty bars later price prints a lower low at 3,950 with RSI at 34. That second bar is a candidate; the rule confirms it five trading days later, when the fifth higher daily low has closed. On that confirmation day the strategy compares 3,950 against 4,000 (lower low) and 34 against 28 (higher low by 6 points, above the 2-point minimum). The regular bullish divergence is complete on the confirmation bar, not on the day of the low. By then price may have moved well off the bottom, and that is the real signal a trader could have acted on.

Rules that peek at the right-side bars before they close create a signal that could never have been traded. The same leak hides in many pattern backtests; common look-ahead leaks and a one-bar check describes how to find it.

How do you place the order and set the stop?

Enter on the open of the bar after the divergence is confirmed, put the stop a fixed distance beyond the second swing point, and exit by a time limit or an opposite signal, so every trade has the same three decisions written in advance. Next-bar execution is the practice of deciding on a closed bar and filling on the next bar, which is the earliest price a rule that reads closes could have traded.

DecisionRule written in advanceWhy this and not the alternative
EntryOpen of the bar after confirmationThe swing low itself is unknown until N bars later; entering "at the low" is a backtest fiction
StopFixed number of ticks or points beyond the second swingA stop tied to the swing keeps the risk per trade comparable across trades; a stop placed by feel cannot be tested
ExitAfter a set number of bars, or on the opposite divergenceA time exit tests whether the signal has any lift on its own; a target can be added once that is known
Around a bullish divergence the entry comes after confirmation, the stop sits a fixed distance below the second swing low, the gap between them is the real risk, and the trade ends at a time exit The gap is the real risk One bullish divergence, schematic Swing Entry Risk Stop Time exit Entry waits; the stop stays put. So: size by entry-to-stop gap.
Where the entry, stop and exit sit around a bullish divergence. The entry comes after confirmation, the stop hangs below the second swing, the exit is a fixed count of bars.

For ES, the E-mini S&P 500 future, one point is worth $50 and one tick of 0.25 point is worth $12.50, so a stop placed 8 points under a swing low risks $400 per contract before slippage. Exchanges can change contract values, so check the exchange's contract page for the market you trade; the free futures contract calculator turns a stop distance in points into dollars for the common contracts.

Hypothetical example

The second swing low in the example above was 3,950. The stop rule says 8 points below the swing, so the stop sits at 3,942. Confirmation came five days later with the next open at 3,990, so the entry is 48 points above the stop: a risk of $2,400 per contract. That gap is the price of waiting for confirmation. A trader who wants a smaller risk per trade has two honest options: a smaller N, which confirms sooner but produces more false swings, or fewer contracts. Moving the stop closer to the entry breaks the link to the swing and changes what is being tested.

A first test is often run with no stop and no target, only the entry signal and its mirror as the exit. That is not carelessness. It measures whether the signal has any lift at all before stops and targets, which have their own optimizer-friendly settings, are allowed to shape the result. The backtest in the last section was run that way.

Which timeframe works better for RSI divergence?

Daily and hourly bars produce few divergences but cleaner swings and a smaller cost share per trade, while 5-minute bars produce many signals whose average move is close to commission and slippage, so the timeframe is chosen by trade count and cost ratio, not by how good the chart looks. Those two numbers pull in opposite directions, and the right bar size is where both are acceptable.

Measure5-minute bars60-minute barsDaily bars
Signals per yearManySomeFew
Time until a swing with N = 5 is confirmed25 minutes5 trading hoursOne trading week
Round-trip cost as a share of the average moveLargeMediumSmall
Years of history needed for a few hundred tradesUnder oneSeveralMore than most data sets hold
The same divergence rule on 5-minute, 60-minute and daily bars: signals per year fall from many to few, confirmation takes 25 minutes, 5 hours or 1 week, and the cost share falls from large to small More trades, more cost Same rule, three bar sizes 5-min 60-min Daily Signals Wait 25 min 5 hours 1 week Cost share Short bars: many trades, big costs. So: weigh trade count vs cost share.
Shorter bars give more signals and a larger cost share; longer bars give fewer signals and a smaller cost share. The timeframe is a trade-off between the two, not a free choice.

The one formula worth writing down is the cost share: cost share = round-trip cost ÷ average move per trade, where the round-trip cost is commission plus slippage for entry and exit together and the average move is what a trade captures before costs. A cost share near one means the signal must be very good just to break even; a cost share of a few percent means the test is mostly about the signal.

Hypothetical example

Round-trip cost on one ES contract: $50. A divergence rule on daily bars captures an average move of 20 points, or $1,000, so the cost share is 5 percent. The same rule on 5-minute bars captures 2 points on average, or $100, and the cost share is 50 percent. On the daily bars a modest loss of edge leaves a result; on the 5-minute bars a small rise in slippage erases it. But the daily rule may produce 20 trades a year and need a decade of data to be judged, while the 5-minute rule reaches a few hundred trades in months.

For a reversal signal that fires rarely, hourly bars are often the compromise: enough trades per year to count, and a cost share small enough that the result is about the signal rather than about the broker. Shorter bars suit indicators that fire often by design; what testing shows about the best indicator for intraday trading covers that side.

What does the ES futures backtest show, trade count included?

The run behind this article kept one candidate out of one thousand and twenty-four tried, using a QQE rule built from RSI as a stand-in for hand-drawn divergence, and its 137 trades on ES daily bars show what a rule-based RSI reversal signal looks like after costs, not what divergence earns. QQE is a smoothed RSI with a trailing band around it, and the kept candidate uses a QQE rule as its only entry and exit, with no stop, no target and no filters. It stands in for divergence because it is built from the same momentum line and fires on the same kind of turn, but it is not a two-swing comparison, so the result is read as a reference point for RSI-based reversal rules and not as a verdict on divergence itself.

Source: AlphaPrime product engine (CPU), run 2026-10-31. ES daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $25 slippage per trade.

NumberResult
Net profit (closed trades)$97,472.5
Max drawdown$50,980
Trades137
Win rate53.28%
Profit factor1.441
Average trade$711.48
Time in market84.7%
Read the trade count next to the net profit and the max drawdown. The number of trades decides how much weight the other numbers can carry.
Read the trade count next to the net profit and the max drawdown. The number of trades decides how much weight the other numbers can carry. ES · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

Three readings matter more than the headline profit. First, 137 trades over about six and a half years is roughly twenty a year, which is a hint rather than a verdict: a sample that small can shift a long way if a handful of trades change. Second, the kept candidate was in the market 84.7 percent of the time, flipping between long and short, which is a very different animal from a divergence rule that fires a few times a year and stays flat in between; a true two-swing divergence rule on daily bars would produce even fewer trades than this. Third, the average trade of $711.48 sits far above the $45 of commission and slippage charged on each trade, so the result is about the signal and not about the cost assumptions, which is the cost-share question from the previous section answered for daily bars.

Follow the equity line into the marked out-of-sample stretch and compare its slope with the earlier part. The drawdown panel under it shows how deep and how long the worst stretch was.
Follow the equity line into the marked out-of-sample stretch and compare its slope with the earlier part. The drawdown panel under it shows how deep and how long the worst stretch was. ES · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

The candidate was picked after the fact as the best of about a thousand by its return against its drawdown, and picking the best one after looking flatters it. Bailey, Borwein, López de Prado and Zhu (2014) show that the more variants are tried on one history, the more the best of them is inflated by luck alone. Park and Irwin (2007), surveying decades of technical-analysis studies, found the same pattern: results shrank when costs and the number of rules tried were accounted for. AlphaPrime (Valynox) charged the $20 commission, the $25 slippage and next-bar fills inside every one of the thousand evaluations through its backtesting, which is why the ranking that produced this candidate was already net of costs rather than a gross result trimmed afterwards; the selection bonus, however, is still in the numbers, and only the out-of-sample stretch in the equity figure and a fresh test on data this run never saw can tell how much of it is luck.

Nothing in this box says that RSI divergence, or QQE, earns $97,472.5 on ES, and no reader should expect that figure. It says that a strictly rule-based RSI reversal signal on daily bars, after costs, produced a positive but small-sample result in this history. What to do next: write the five rules from the first section for your own market, run them on daily bars with no stop and no target, and count the trades. If the count is under about 30, move to hourly bars and count again before you look at any other number.

Frequently asked questions

Does RSI divergence work?

It can only be answered for a specific written rule: swing strength, maximum distance between swings, minimum RSI difference, entry bar, stop and exit. Judged by eye after the move, divergence always seems to work because the failed cases are never drawn. On ES daily bars a rule-based RSI reversal stand-in produced 137 trades after costs in six and a half years, which is enough to be interesting and too few to be a verdict.

What is hidden RSI divergence?

Hidden divergence is RSI making a new extreme while price does not. In an uptrend, price makes a higher low while RSI makes a lower low; in a downtrend, price makes a lower high while RSI makes a higher high. It is read as a continuation signal, the opposite of regular divergence, so a test must state in advance which form it is looking for.

How do you trade RSI divergence?

Detect swings with a fixed number of bars on each side, confirm the second swing only after its right-side bars close, and compare the two price swings with the RSI values on the same two bars. Enter on the open of the bar after confirmation, place the stop a fixed distance beyond the second swing, and exit after a set number of bars or on the opposite signal. Write all three decisions down before the first test.

Which timeframe is best for RSI divergence?

The one that gives enough trades to count and a small enough cost share to be about the signal. Daily bars give clean swings and a small cost share but few trades; 5-minute bars give many trades but a cost share that can approach half the average move. Hourly bars are often the compromise for a signal that fires rarely.

References

  • Wilder, J. W. (1978). New Concepts in Technical Trading Systems. Trend Research.
  • Lo, A. W., Mamaysky, H., & Wang, J. (2000). Foundations of Technical Analysis: Computational Algorithms, Statistical Inference, and Empirical Implementation. The Journal of Finance, 55(4), 1705–1765.
  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
  • Park, C.-H., & Irwin, S. H. (2007). What Do We Know About the Profitability of Technical Analysis? Journal of Economic Surveys, 21(4), 786–826.