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.
Best run of 2. US Crude Oil, 4 hours, spread 3, from run sweeps:2026-10-12-CRUDE-4h-opt.tsv:12.
| Period | Up to 2026-10-12 |
| Instrument | US Crude Oil, 4 hours |
| Spread | 3 points |
| Starting capital | 1,000,000 |
| Costs | Spread only. Commissions and overnight financing are not included. |
| Bars | Up to 200,000 bars, fewer where the instrument has less history |
| Last tested | 2026-10-12 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| US Crude OilBest run | 4 hours | n/a | 832 | 37.14 | 2,959 EUR | -2,944 |
| Dow Jones | Daily | n/a | 507 | 35.31 | 10,191 EUR | -6,667 |
Charts
The code
// ============================================================== // 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
Questions
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.
It was tested on 2 market and timeframe combinations. The best run by trade count was US Crude Oil, 4 hours, with 832 trades.
The best run had a maximum drawdown of 2,944 EUR at the tested position size, against a net result of 2,958 EUR.
It trades both long and short.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.