All indicators

RSI Divergence: Out-of-Sample Optimizer

By LuxAlgoJun 9, 2026

Static chart image

RSI Divergence: Out-of-Sample Optimizer turns divergence trading into a controlled experiment: it simulates regular bullish and bearish divergences between price and RSI across an entire range of RSI periods, ranks them by your chosen metric, and tests whether the winner survives on data it never saw. Divergences follow the standard definitions (a lower low in price paired with a higher RSI low, or the bearish mirror), confirmed by pivot lookbacks.

Three chronological phases mirror the in-sample/out-of-sample split: In-Sample optimization scans every period, Out-of-Sample validation locks the best one and replays it on unseen data, and Forward testing carries the validated setting to the current bar.

How to Trade the RSI Divergence: Out-of-Sample Optimizer?

  • In-Sample winner: the RSI period topping your Optimization Metric (Net Profit, Profit Factor, Sharpe Ratio, or Win Rate).
  • Out-of-Sample verdict: whether the edge persisted out of sample or evaporated as curve fit.
  • Sensitivity Table: a heatmap of every tested period. A broad green cluster suggests robustness, a lone spike is a warning.
  • Simulated trade rules: entries fire the bar after a confirmed divergence; exits use ATR-multiplied stops and targets, with optional Exit on Opposite Signal.

RSI Divergence: Out-of-Sample Optimizer Settings

  • In-Sample Start/End / Out-of-Sample Start/End: the optimization and validation windows.
  • Min/Max RSI Period: the range of RSI lengths simulated.
  • Optimization Metric: the KPI used to rank periods.
  • Pivot Left/Right Bars: bars required either side to confirm an RSI pivot.
  • Max Divergence Bars: maximum pivot distance for a valid divergence.
  • Stop Loss/Take Profit ATR Multiplier and Exit on Opposite Signal: the simulated exit logic.
  • Extra Dashboard Metric 1/2, Dashboard Position/Size: extra statistics and dashboard placement.

Frequently Asked Questions

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5
Original indicatorBuilt in-house by LuxAlgo

The Library is free. Quant makes it yours.

Pull any concept or indicator into Quant: rebuild it, retune it, or turn it into a backtested strategy of your own.