Join today
Strategies / Mean reversion / Oscillator Mean Reversion

Oscillator Mean Reversion

The oscillator is a 5-day average of (close - open) / (high - low). When it drops below -0.2 while the 5-day SMA is above the 50-day SMA, the system buys, and the mirror setup sells short. Trades use a 50 point target and a 40 point stop, and an opposite signal reverses.

Mean reversionLong & shortSwingS&P 500Daily
1.18Profit factor
1,818Net profit EUR
46.73%Win rate
627Trades
-382Max drawdown
2.90Avg trade

Best run of 6. S&P 500, Daily, spread 1, from run pf:2026-09-24-USA500-D.tsv:10.

Entry rules, long

  1. The 5-day SMA is above the 50-day SMA
  2. Members only

Entry rules, short

  1. The 5-day SMA is below the 50-day SMA
  2. Members only

Exit rules

  1. Members only
  2. Stop loss 40 points
  3. An opposite signal reverses the trade

Test conditions

PeriodUp to 2026-09-25
InstrumentS&P 500, Daily
Spread1 points
Contracts1
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-09-25

Parameters

positionSize
Size per point
1
fastPeriod
Fast SMA length
5
slowPeriod
Slow SMA length
50
bodyRatioPeriod
Days averaged for the body ratio
5
bodyRatioLevel
Average body ratio must be beyond plus or minus this
0.2
takeProfitPoints
Profit target in points
50
stopLossPoints
Protective stop in points
40

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
S&P 500Best runDaily1.18 62746.731,818 EUR-382
USD/JPYDailyn/a 1,51948.12493,600 JPY-142,000
EUR/USDDailyn/a 1,44247.0934,097 USD-16,473
Dow JonesDailyn/a 1,40746.622,608 EUR-1,360
Gold4 hoursn/a 96643.58927 EUR-924
GoldDailyn/a 47846.03888 EUR-414

Charts

Results by run

Net profit against max drawdown

Net profitMax drawdown
0-200K-100K250K500KUSD/JPY · DailyEUR/USD · DailyDow Jones · DailyS&P 500 · DailyGold · 4 hoursGold · Daily

The code

ProBuilder, rewritten to house standard

Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.

// ============================================================
// Oscillator Mean Reversion
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Mean reversion
// Direction: Long & short
// Timeframe tested: Daily
// ============================================================

// --- Settings ---
DEFPARAM CumulateOrders = false

// --- Parameters ---
positionSize = 1       // size per point
fastPeriod = 5         // fast SMA length
slowPeriod = 50        // slow SMA length
bodyRatioPeriod = 5    // days averaged for the body ratio
bodyRatioLevel = 0.2   // average body ratio must be beyond plus or minus this
takeProfitPoints = 50  // profit target, points
stopLossPoints = 40    // protective stop, points

// --- Indicators ---
maOscillator = Average[fastPeriod](close) - Average[slowPeriod](close)

// Day body as a share of the day range: +1 closes at the high from the low, -1 the reverse.
dayBodyRatio = (DClose(0) - DOpen(0)) / ABS(DHigh(0) - DLow(0))
avgBodyRatio = Summation[bodyRatioPeriod](dayBodyRatio) / bodyRatioPeriod

16 more lines: the entry and exit rules.

Read this first

Known weaknesses

  • Profit factor on the best S&P 500 daily run is 1.18, with EUR 1,817.76 net over 627 trades.
  • Stop and target are in points, so the same 50 and 40 points mean very different risk across the S&P 500, Gold and currency pairs.
  • Only 5 other runs are listed, and none of them has a recorded profit factor.

Indicators used

SMA

How to load it

  1. Copy the code with the copy button above 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.

Questions

About this strategy

Can this run in ProOrder?

Yes, it is fully automated and sized per point. The code was rewritten after testing and not compile-checked, so test it in ProBacktest first.

Which markets were tested?

S&P 500 gave the best recorded run. USD/JPY daily made JPY 493,600 in a sweep with a JPY 142,000 drawdown, and EUR/USD, Dow Jones and Gold were also positive.

What drawdown should I expect at 1 contract?

The S&P 500 daily best run had a max drawdown of EUR 381.56 at position size 1.

Why daily bars?

The trend and oscillator filters are built from daily averages, and the daily chart produced every listed result except Gold 4 hours.

Related

Strategies like this one

Bollinger Squeeze

Uses the same indicator.

14.30 PF · 86 trades

Candle Body Sum Intraday

Best run on the same market, S&P 500.

2.86 PF · 124 trades

Awesome Oscillator EMA Cross

A similar profit factor.

1.19 PF · 769 trades

Mean reversion is one part of a balanced setup. Join the ProRealAlgos waitlist to see the full picture.

Copy trading on US indices is available to ProRealAlgos members as spots open.

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