RealTest Strategies / RealTest SPX Mean-Reversion

RealTest SPX Mean-Reversion

A systematic mean-reversion strategy for S&P 500 stocks built in RealTest. It identifies statistically oversold conditions using rate-of-decline filters and enters via limit orders to provide liquidity during broad selloffs. Backtested since 2000 with survivorship-bias-free Norgate data, validated through walk-forward analysis and Monte Carlo simulation.

Live traded since Jan 2024Trading costs included Survivorship-bias-free data
$100k$300k$1.0M$3.0M$10.0M'02'04'06'08'10'12'14'16'18'20'22'24'26 Live $12.3M $592k
Strategy SPY buy & hold
Sharpe ratio?
1.16
+142%vs SPY 0.48
Best year?
+140.8%
5.2×SPY best: 27.0% in 2003
Max drawdown?
-21.8%
56% smallervs SPY -49.9%

Validated four ways

See how each test is run →

Live market performance
Performs in real market conditions since 2024-01-30
Verified
Statistical validation
Validated across in-sample & out-of-sample data
Passed
Walk forward analysis
Tests robustness across unseen data
Passed
Monte Carlo stress test
Resilient against 1,000+ sequence risk simulations
Passed

What happened in every crash

CrisisDatesStrategySPYSame $100k in
Dotcom crash Mar 2000 – Oct 2002 108.3% -41.8%
2008 financial crisis Oct 2007 – Mar 2009 13.4% -49.9%
COVID-19 crash Feb 2020 – Mar 2020 -0.5% -28.7%
2022 bear market Jan 2022 – Oct 2022 22.8% -21.3%

Strategy monthly returns

JanFebMarAprMayJunJulAugSepOctNovDecYear
20006.517.713.712.713.64.6-0.9-0.23.016.84.91.1140.8%
2001-2.76.73.51.70.50.87.2-0.3-9.0-0.82.52.312.0%
2002-1.72.0-1.82.00.11.9-3.21.94.03.82.22.013.6%
2003-2.83.31.00.06.10.34.31.72.91.03.40.023.0%
20042.20.92.7-4.51.20.0-1.72.30.00.4-0.70.93.5%
2005-4.5-0.23.93.30.21.0-0.20.02.1-3.20.01.94.0%
20066.20.26.80.8-6.53.60.90.00.02.10.30.014.7%
20070.00.21.30.02.43.7-1.23.71.01.9-3.63.313.2%
2008-13.43.03.51.28.33.04.1-0.711.65.51.8-1.627.1%
20090.7-13.53.25.01.42.92.10.08.07.42.63.924.5%
2010-1.611.60.05.111.1-7.74.4-1.64.00.03.80.331.6%
20110.03.30.92.64.3-6.11.5-8.47.67.62.01.917.2%
20120.00.02.92.2-2.66.8-4.01.8-0.84.43.62.217.3%
20131.5-2.70.30.8-0.74.92.50.90.24.4-0.8-0.910.6%
2014-0.11.00.33.61.60.0-1.9-0.24.23.80.01.514.7%
20151.9-0.34.7-0.10.01.43.31.0-2.31.64.42.118.8%
2016-5.02.00.5-1.3-0.94.91.6-0.11.7-0.32.00.35.1%
20171.70.00.30.90.0-1.00.53.50.00.00.40.06.4%
20180.01.3-2.32.21.1-1.70.40.00.63.26.1-7.03.4%
2019-0.10.02.60.0-0.83.60.01.40.02.00.04.313.6%
2020-1.80.47.5-0.32.43.31.40.02.70.47.50.325.9%
20210.01.017.54.91.92.07.66.64.30.80.06.366.0%
20222.26.711.65.76.2-13.93.02.1-2.13.84.11.232.4%
20230.5-2.9-2.80.4-1.30.50.01.7-0.3-1.63.70.0-2.3%
20242.70.01.43.70.54.51.50.54.60.00.00.121.0%
20254.3-6.8-1.22.70.90.00.06.40.00.03.45.715.7%
20263.20.45.20.50.00.1-1.50.80.08.8%

Strategy overview

Mean-Reversion Methodology

This strategy measures the velocity and magnitude of price decline in S&P 500 constituents relative to their recent trading range. When a stock reaches a statistically defined oversold threshold, it generates a limit order entry. The logic is designed around the empirical observation that large-cap equities tend to revert after sharp short-term dislocations, particularly when the decline is driven by broad market sentiment rather than company-specific events.

Execution and Liquidity

Entries use calculated limit orders rather than market orders, which serves two purposes: it improves average fill price and naturally filters for the deepest oversold conditions. The S&P 500 universe ensures sufficient liquidity for realistic execution at the modeled prices. Backtests include Interactive Brokers tiered commissions and a limit order buffer to account for real-world fill dynamics.

Portfolio Context

Mean-reversion strategies tend to exhibit low correlation with trend-following and momentum systems. Adding this type of strategy to a portfolio that already holds long-term or momentum-based positions can reduce overall equity curve volatility. The strategy is most active during elevated-volatility regimes, providing returns in the periods where buy-and-hold exposure typically suffers the largest drawdowns.

Specification

StyleMean reversionUniverseS&P 500 current & past stocksTimeframeDailySideLongAverage hold6 trading daysTrade frequency3.2 per monthEntry executionLimit orderExit executionLimit orderDataNorgate Data (US Stocks Platinum) SoftwareRealTestCommission$0.005 / shareLimit price buffer0.1% past limitSPY benchmarkNo fees applied (favors SPY)

What you get

RealTest by MHP Trading logo
RealTest strategy code (.rts)
Complete RealTest (.rts) strategy code. Import, backtest, and modify.
Trading strategy rules plain text document
Plain text rules
Trade it on any platform without reading the code.

Quick start & live trading

RealTest trading software logo
Quick start guide
From download to first backtest in 1 minute
1
You download the .rts file
Click download
2
You open it in RealTest
File → Open → Select file
3
You import symbols
Click import
4
You run the backtest
Click test
OrderClerk automated trading execution interface
Daily live trading
For RealTest automated execution
1
Open OrderClerk
Click 'Connect to IB'
2
Import signals
Click 'Import' in RealTest
3
Generate orders
Click 'Orders' in RealTest
4
Execute trades
Click 'Place Orders'

What traders say

Buying a SetupAlpha strategy didn't save me money, it saved me research time. I estimate it replaced 70–90 hours of development, debugging, and validation. Even if I never trade the strategy exactly as delivered, the research process was worth the investment.

Roman Blackwood
Roman Blackwood
Founder of AI in Trading (+13K subscribers)

I've been using a strategy from SetupAlpha and I'm really impressed with its elegance and stability. The unique approach gives me a fresh perspective and ideas I can apply to other strategies I'm developing. I'm currently working on integrating it into my suite of trading strategies.

TradeQuantiX
TradeQuantiX
Multi-country systematic trader (+4.7K subscribers)

I traded discretionary for over a decade and kept putting off going systematic because I did not know where to start. Having a finished, tested system to take apart was what finally got me moving.

Daniel
Daniel
Crypto trader

I have run it live since 2024 and it is still in my portfolio. It also changed how I test the systems I build myself.

Systematic Traders
Systematic Traders
Algo trader & Substack writer (+6.4K subscribers)

FAQ

What is RealTest SPX Mean-Reversion?
A systematic mean-reversion strategy for S&P 500 stocks built in RealTest. It identifies statistically oversold conditions using rate-of-decline filters and enters via limit orders to provide liquidity during broad selloffs. Backtested since 2000 with survivorship-bias-free Norgate data, validated through walk-forward analysis and Monte Carlo simulation.
What is RealTest and what software do I need?
RealTest is a backtesting and trade automation platform for systematic traders, built by Martin Parker at MHP Trading. Each strategy comes as an .rts file you import directly. To trade it live you add OrderClerk and an Interactive Brokers account.
How was this backtested?
Survivorship-free Norgate data from January 2000 to the present, with out-of-sample walk-forward analysis and over 1000 Monte Carlo simulations to test stability.
Are transaction costs included?
Yes. The results include Interactive Brokers commissions, and a limit-order buffer of 0.1% past limit, so the equity curve is after costs.
When did live trading start?
Live trading started in January 2024. The equity curve shows the backtest from 2000 and real performance from that point on.
What's included in the download?
RealTest .rts file (complete source). Plain-text trading rules. Full documentation with parameter explanations.
How does it compare to SPY?
The chart at the top plots this strategy against SPY, the S&P 500 ETF, from 2000 with both starting at $100,000. A metrics table lists the exact numbers side by side: Sharpe, Sortino, net profit and worst year, for the strategy and for SPY over the same period.
Can I modify the code?
Yes. You get the complete source code with a perpetual license, so you can adjust parameters, change position sizing, combine it with other systems, or use it as a starting point for your own research.
What market data do I need?
Norgate Data (recommended) for survivorship-free US equities. Yahoo Finance works for basic testing but lacks delisted stocks. The backtest results shown here use Norgate Platinum.
Can I automate execution?
RealTest to OrderClerk to Interactive Brokers. Generate signals daily in RealTest, execute automatically via OrderClerk to IBKR. Setup course available.
Can I ask questions about the code or the strategy?
Yes. Email setupalpha.capital@gmail.com and you will get an answer, before or after you buy.

Changelog

2024-01-30Rules finalised. Live tracking starts.

No rule changes since.

Portfolio growth since 2000
12,194.9%
SPY same period: 492.5%
$899one-time
Instant download
MetricStrategySPY
Sharpe1.160.48
ROR19.74%
Sortino0.810.46
MAR0.9
Net profit$12.2M$492k
Expectancy2.47%
Max exposure100.53%100%
Worst year-2.3%-33.2%

Download the complete strategy now

Active Script - C:\REALTEST\Strategies\spx_mean_reversion.rts
RealTest SPX Mean-Reversion full RealTest script
Trading strategy rules plain text document
Plain text rules
Trade it on any platform without reading the code.
RealTest SPX Mean-Reversion
$899one-time
Instant download