Strategy Guide

Backtest a mean-reversion strategy with plain language

One of investing's oldest intuitions — "what goes down tends to come back up" — is surprisingly testable. Type the rule the way you'd describe it to a colleague: RSI threshold, a trend filter, a minimum hold. Porfie translates plain language into an actual backtest, and the choice of stocks turns out to matter as much as the strategy itself.

⏱ 9 min · May 2026 · RSI + trend filter Portfolio comparison Plain-language backtest

Porfie is a backtesting and portfolio exploration tool for educational use. Nothing on this site is financial advice.

There's a pattern that shows up in markets again and again: a stock slides for a few weeks, the mood around it turns sour, and then — quietly, without announcement — it drifts back toward where it started. Traders have a name for this tendency. They call it mean reversion, and it's been studied, debated, and traded for longer than most modern financial instruments have existed.

The question isn't whether the idea is interesting. It's whether it actually holds up when you run it against real data — and which kinds of stocks it works on best. With Porfie, that question has a straightforward answer: describe both the portfolio and the strategy in plain language, and the backtest builds itself. RSI threshold, trend filter, minimum hold time — say it the way you'd say it out loud, and Porfie reads each clause. Think of it as vibe quant — turning a market intuition into a result you can actually look at.

What is mean reversion?

Imagine stretching a rubber band. The further it's pulled from its resting position, the stronger it wants to snap back. Mean reversion treats stock prices similarly: when a price strays far from its recent average behaviour, there's a tendency — not a certainty, but a tendency — for it to drift back.

The classic signal is the RSI (Relative Strength Index). It measures how aggressively a stock has been sold off relative to its own recent price swings, on a scale from 0 to 100. An RSI below 30 is generally considered "oversold" — the rubber band is stretched. A mean-reversion strategy buys at this point and waits for the snap-back.

Why RSI and not just "the price dropped a lot"?

A 10% drop means something very different for a volatile tech stock versus a steady utility. RSI normalises the move relative to that stock's own typical swings, so the signal fires at a meaningfully oversold level for each stock — not just any stock that happened to fall on a bad week.

Mean reversion tends to show up most reliably in stable, well-established companies: utilities, consumer staples, large healthcare names. Their earnings don't change much quarter to quarter, so when their price dips sharply, it's more likely the market overreacting than the business deteriorating. On more volatile, cyclical stocks, the same signal works differently — sometimes better, often bumpier. That's exactly what we'll test by comparing two different portfolios below.

How Porfie splits strategy building into two steps

Porfie handles strategy building in two separate prompts — a useful distinction that mirrors how quantitative strategies actually work:

1
Fundamentals Portfolio builder — which stocks?
Describes the stock universe using company data from financial reports — revenue, profitability, dividends, debt, sector. Once saved, this portfolio becomes the candidates the strategy will trade from.
2
Technical Strategy / Vibe — when to trade?
Describes the trading rules using price-based technical indicators — RSI, moving averages, MACD, momentum. This defines when to enter and exit positions within the saved portfolio.

The backtest runs against the saved portfolio, so the order matters: build the portfolio first, save it, then apply the strategy and run. Let's do exactly that.

Step 1 — Build and save a portfolio

For mean reversion to work, the choice of stocks matters enormously. We'll build two different portfolios from company fundamentals and test the same strategy on each — the comparison reveals more than either result alone.

Portfolio A
"Steady Payers"
Utilities Consumer Staples
Stable earnings · predictable revenue · low volatility. The natural home of mean reversion.
Portfolio B
"Value Dippers"
Industrials Financials
Cyclical · higher revenue floors · more volatile. A harder test for the same strategy.

Portfolio A — "Steady Payers"

Portfolio A Screening Prompt
Fundamentals
10 US large-cap stocks from utilities or consumer staples sectors with positive net income in each of the past 3 years and annual revenue above $8 billion. Rank by revenue.
Paste into Porfie's portfolio builder, review the stock list, then save the portfolio.

Every condition here serves the same purpose: find companies whose fundamentals change very slowly. Three years of positive net income rules out businesses losing money. The $8B revenue floor keeps the focus on large, established names in slow-moving sectors. The revenue ranking puts the most dominant businesses first.

Review before saving

Porfie's portfolio builder is a ranked shortlist, not a hard filter — occasionally a company with incomplete data or an edge case slips through. Before confirming, glance at the net income column and deselect anything showing a loss or a sector that clearly doesn't fit. It takes 30 seconds and keeps the portfolio honest.

In backtests, when Portfolio A's RSI dips below 30 AND the stock is still trading above its 200-day moving average, it has historically corresponded to a short-term sell-off inside a longer uptrend — a clean mean-reversion setup. That's the combination the strategy is set up to detect.

Portfolio B — "Value Dippers"

Portfolio B Screening Prompt
Fundamentals
10 US large-cap stocks from industrials or financials sectors with positive net income in at least 4 of the past 5 years and annual revenue above $5 billion. Rank by revenue.
Paste into Porfie's portfolio builder, review the stock list, then save as a separate portfolio.

Portfolio B selects companies that are fundamentally sound — real revenue, mostly profitable — but more sensitive to economic cycles. Industrials and financials swing harder with the macro. The $5B revenue floor still filters out smaller companies, but this universe carries more inherent volatility. An RSI dip here might be a short-term overreaction, or it might reflect something the market is genuinely repricing. In the backtest data, the same signals produce a different character on this universe: larger swings in both directions.

The screener ranks by revenue, so glance at the generated list before saving — the top results should be names you recognise from the sector.

Why build two?

Running the same strategy on both portfolios answers a question the strategy alone can't: how much roughness are you willing to tolerate for potentially higher returns? Portfolio A is the calmer version. Portfolio B is the more dramatic one. Seeing both side by side is more instructive than either alone.

Step 2 — Add the strategy and run the backtest

With a portfolio saved, the trading rule is the same for both. The strategy below is mean reversion with two guardrails — a trend filter to avoid "falling knife" entries, and a minimum hold time to prevent same-week round trips on noise. Paste it into Porfie's strategy / vibe field:

Strategy Prompt (for both portfolios)
Technical
Use a 21-day RSI. Buy when RSI drops below 30 — only enter on genuinely oversold conditions. Only enter if the stock's price is above its 200-day moving average (buying a dip in an uptrend, not a falling knife). Hold each position for at least 5 trading days before allowing an exit. Sell when RSI rises above 65.
Paste into Porfie's strategy / vibe field, then select the saved portfolio and run.

What each clause is doing:

Each clause maps to a configuration on Porfie's signal-driven basket engine: indicator + period, entry threshold, AND-filter condition, minimum hold days, exit threshold. Nothing else is implicit — the strategy you describe is the strategy that runs.

Run it on Portfolio A first. Note the results. Then switch to Portfolio B with the same strategy and the same time window (a 5–10 year window is ideal — long enough to include at least one meaningful market downturn).

What the comparison shows

Both backtests ran from Jan 2019 – Dec 2025 with $100,000 initial capital, using the same RSI + trend-filter + 5-day-hold strategy on each portfolio.

Metric Portfolio A — Steady Payers Portfolio B — Value Dippers
Win rate 60.3% — most dips bounced 65.6% — slightly higher hit rate
CAGR 8.72% (Jan 2019–Dec 2025) 6.35% — meaningfully lower
Max drawdown −41.4% — sharp but recovered −44.2% — slightly deeper
Sharpe ratio 0.32 — better return per unit of risk 0.21 — noticeably worse
Profit factor 1.94 — wins clearly exceed losses in size 1.62 — narrower margin
Avg holding 189 days — patient exits 176 days — slightly shorter
Final value $179K from $100K initial $154K from $100K initial

Here's the part that surprises most people: Portfolio B had a higher win rate — 65.6% vs 60.3% — and still ended with meaningfully lower returns. More of its trades made money, but the losers were bigger.

That's the gap profit factor exposes (1.94 vs 1.62). Portfolio A's average win was a larger multiple of its average loss; Portfolio B's wins came more often but the occasional severe loss ate into them. Cyclical industrials and financials produce more RSI < 30 entries than utilities — but when the macro genuinely turns (rate shocks, credit stress, recession), those names can stay broken longer than a 5-day hold can absorb.

The Sharpe ratio (0.32 vs 0.21) is the fairest single-number comparison: it measures return per unit of risk, capturing both the lower raw return AND the higher volatility of Portfolio B. A 50% gap in Sharpe is substantial — Portfolio A delivered noticeably more return for the same risk budget. This is the opposite of what the win-rate alone suggests, and exactly the kind of insight a backtest gives you that intuition wouldn't.

Portfolio A — Steady Payers (Utilities & Consumer Staples) backtest charts from Porfie: equity curve growing from $100K to $179K, drawdown reaching −41%, and position allocation, Jan 2019–Dec 2025, RSI 30/65 mean-reversion strategy with 200-day MA filter and 5-day minimum hold
Portfolio A — Steady Payers Utilities & Consumer Staples · Jan 2019–Dec 2025 · $100K initial · RSI(21) <30 / >65, price > 200-day MA, min 5-day hold +79.3% total · CAGR 8.72% · Max drawdown −41.4% · Sharpe 0.32
Portfolio B — Value Dippers (Industrials & Financials) backtest charts from Porfie: equity curve growing from $100K to $154K, drawdown reaching −44%, and position allocation, Jan 2019–Dec 2025, RSI 30/65 mean-reversion strategy with 200-day MA filter and 5-day minimum hold
Portfolio B — Value Dippers Industrials & Financials · Jan 2019–Dec 2025 · $100K initial · RSI(21) <30 / >65, price > 200-day MA, min 5-day hold +53.7% total · CAGR 6.35% · Max drawdown −44.2% · Sharpe 0.21

Key metrics to watch in the results

Win Rate
60.3%
Portfolio A result — most RSI dips bounced back, but win rate alone doesn't tell the full story.
CAGR
8.72%
Portfolio A annual return, 2019–2025.
Max Drawdown
−41.4%
A steep simulated trough — even stable sectors weren't immune to the 2020 / 2022 stress periods.
Sharpe Ratio
0.32
Return per unit of risk — A's 0.32 vs B's 0.21 is the cleanest one-number comparison.

One number worth calling out: the average holding period was 189 days for Portfolio A and 176 days for Portfolio B — far longer than most people expect from an "RSI strategy". With the trend filter blocking entries during downtrends and the 5-day minimum hold suppressing immediate exits, simulated positions tend to stay open until RSI actually recovers to 65 — and that can take months. The strategy holds more like a medium-term investor than a short-term trader. Don't expect rapid in-and-out trades.

The number that surprises most people

Max drawdown almost always looks worse than expected going in. Portfolio A returned 79% over the test period — but it also passed through a −41% trough along the way. Portfolio B returned less and still hit a −44% drawdown. As the vibe quant intro puts it: the value of a backtest isn't just the final return number. It's pre-experiencing what the ride actually felt like — so you can decide whether you'd trust the strategy through the hard part before any real money is involved.

Things to tweak after your first run

Once there are baseline results on both portfolios, try adjusting one variable at a time. Each change tells you something different about how the strategy actually works:

None of this requires rewriting anything — just adjust the prompt values and run again. The answer is usually in the comparison, not the absolute number.


Educational content only. Everything on this page — the prompts, the backtest results, the comparisons — is for learning and data exploration. Porfie is a backtesting sandbox. None of this constitutes financial advice, investment recommendations, or any suggestion about how to manage real money. Past backtest results do not predict future performance. Always consult a qualified financial professional before making investment decisions.

An honest note on limitations

Mean reversion works in some market conditions and fails in others. During sustained downtrends — when the market is genuinely repricing something lower — buying an oversold RSI signal means catching a falling knife. Portfolio A's stable-sector filters provide some protection; Portfolio B is more exposed. Seeing this play out across a backtest window that includes a real downturn is part of what makes the exercise valuable.

Backtests also can't capture transaction costs, bid-ask spreads, or the simple fact that the future isn't obliged to look like the past. "Past performance doesn't guarantee future results" is a cliché because it's true. What a backtest gives you is a realistic feel for the strategy's rhythm — how often it trades, how bumpy the ride is, whether the underlying logic holds up across different conditions. That's worth knowing before any real money is on the table.

Run the comparison yourself

Build Portfolio A, save it, run the RSI strategy. Then do the same with Portfolio B. The difference between the two results is where the real learning happens.

Start exploring on Porfie →