Join waitlist
Strategies / Trend / Rainbow Trend With RSI Divergence

Rainbow Trend With RSI Divergence

Trades trend turns in a rainbow of smoothed averages of typical price, when an RSI filter or RSI divergence confirms the turn. Positions close when the trend flattens, or when a 3.5 x ATR move or 3% move goes against the trade.

TrendLong & shortSwingUS Crude Oil4 hours
n/aProfit factor
2,959Net profit EUR
37.14%Win rate
832Trades
-2,944Max drawdown
3.56Avg trade

Best run of 2. US Crude Oil, 4 hours, spread 3, from run sweeps:2026-10-12-CRUDE-4h-opt.tsv:12.

Entry rules, long

  1. The RSI filter passes when RSI(12) is between 35 and 65 and the previous RSI(9) is outside 44 to 56.
  2. Alternatively, a bullish RSI(10) divergence passes the filter when the previous RSI(9) is between 44 and 56.
  3. A long is opened at market when the trend turns up with the filter passed and no long position is open.

Entry rules, short

  1. The same RSI filter applies, with RSI(12) between 35 and 65 and the previous RSI(9) outside 44 to 56.
  2. Alternatively, a bearish RSI(10) divergence passes the filter when the previous RSI(9) is between 44 and 56.
  3. A short is opened at market when the trend turns down with the filter passed and no short position is open.

Exit rules

  1. A trend change without a valid signal also closes the position.
  2. A position closes when price moves 3.5 times the 6-bar ATR in its favor from the signal close.
  3. A position closes when price moves 3.5 times the 6-bar ATR or 3% against it from the signal close.

Test conditions

PeriodUp to 2026-10-12
InstrumentUS Crude Oil, 4 hours
Spread3 points
Starting capital1,000,000
CostsSpread only. Commissions and overnight financing are not included.
BarsUp to 200,000 bars, fewer where the instrument has less history
Last tested2026-10-12

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
US Crude OilBest run4 hoursn/a 83237.142,959 EUR-2,944
Dow JonesDailyn/a 50735.3110,191 EUR-6,667

Charts

Results by run

Net profitMax drawdown

The code

ProBuilder code, as tested

// ==============================================================
// Rainbow Trend With RSI Divergence
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: 4 hours
// ==============================================================

DEFPARAM CumulateOrders = false

ONCE divstatus = 0
ONCE bullval = 0
ONCE bearval = 0
ONCE plong = 0
ONCE pshort = 0
ONCE dir = 0

maa = Average[12](TypicalPrice)
mab = Average[3](maa)
mac = Average[3](mab)
mad = Average[3](mac)
mae = Average[3](mad)
maf = Average[3](mae)
mag = Average[3](maf)
rbmax = MAX(maa, MAX(mab, MAX(mac, MAX(mad, MAX(mae, MAX(maf, mag))))))
rbmin = MIN(maa, MIN(mab, MIN(mac, MIN(mad, MIN(mae, MIN(maf, mag))))))
IF maa = rbmax THEN
    dir = 1
ELSIF maa = rbmin THEN
    dir = -1
ELSE
    dir = 0
ENDIF

rsia = RSI[12](close)
rsib = RSI[9](close)
rdh = RSI[10](high)
rdl = RSI[10](low)
rdc = RSI[10](close)

90 more lines: the entry and exit rules.

Setup

How to load it

  1. Copy the code with the copy button on the code block.
  2. In ProRealTime, open a chart of the instrument and timeframe you want to test, then open ProOrder > New trading system and choose "Create with programming".
  3. Paste the code, give the system a name and save it.
  4. Click "Backtest", set your own spread and position size, and run it before you consider trading it live.

Indicators used

SMARSIATR
Read this firstKnown weaknesses3 points
  • No profit factor is available, because only sweep results exist for this strategy.
  • The maximum drawdown of 2,944 EUR is large next to the net profit of 2,958 EUR.
  • The code sets no stop loss, so a losing trade stays open until an exit signal arrives.

Questions

About this strategy

Can I run Rainbow Trend With RSI Divergence in ProOrder?

Yes. The code is ProBuilder and runs as an automated ProOrder system. Backtest it on your own account with your own spread and position size before trading it live.

Which markets was it tested on?

It was tested on 2 market and timeframe combinations. The best run by trade count was US Crude Oil, 4 hours, with 832 trades.

How large was the drawdown?

The best run had a maximum drawdown of 2,944 EUR at the tested position size, against a net result of 2,958 EUR.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

Trend Surfer

Uses the same indicator.

1.04 PF · 10,813 trades

Short Term RSI Pullback Long Short

Best run on the same market, US Crude Oil.

1.33 PF · 493 trades

ADX Filtered EMA Cross

Also a trend strategy.

1.15 PF · 607 trades

Put your name on the ProRealAlgos waitlist to trade a tested portfolio instead of single strategies.

The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.

Past backtest results do not guarantee future results. This is not financial advice. Curated and maintained by ProRealAlgos. ProRealTime™ is a trademark of ProRealTime SAS. prorealalgos.comStatsDocs