On this page
The standard advice is "buy RSI below 30, sell RSI above 70." The standard advice loses money. RSI mean reversion can work — it's a real edge in range-bound markets and a real disaster in trending ones — but you have to build the strategy correctly. This walkthrough builds one from the ground up, with the rule set, the validation, and the failure modes.
1. What RSI actually measures
RSI is a normalized momentum oscillator. It looks at the recent N bars (default 14), separates them into bars that closed up vs. bars that closed down, averages the magnitudes of each, and returns a number between 0 and 100. High readings = strong recent up-momentum. Low readings = strong recent down-momentum. That's it. There is nothing intrinsic about 30 or 70 — they're a convention from Welles Wilder's 1978 book and they're approximate.
# For each of the last 14 closes, compute the change.
# Split into gains (positive changes) and losses (negative).
avg_gain = mean(gains over last 14 bars)
avg_loss = mean(losses over last 14 bars)
RS = avg_gain / avg_loss
RSI = 100 - 100 / (1 + RS)
# RSI of 70 means avg_gain is ~2.3x avg_loss over the window.
# RSI of 30 means avg_loss is ~2.3x avg_gain.2. The naive strategy and why it fails
Buy when RSI(14) crosses up through 30, sell when it crosses up through 70. On a 4h BTC backtest from 2020 to 2025 this loses money. Why? Because in a sustained uptrend, RSI sits above 70 for weeks (you exit the trend early and miss the moves) and in a sustained downtrend, RSI sits below 30 for weeks (you buy three times in a falling knife before stopping out).
The fix is two-fold. First, only fire the mean-reversion signal when the market is actually mean-reverting, not trending. Second, manage risk with a proper stop and a defined exit logic, not just "sell when RSI gets high."
3. Adding a regime filter
ADX (Average Directional Index) measures trend strength. Low ADX (under 20 or so) = ranging market. Higher = trending. By gating the RSI signal on ADX, we only buy oversold conditions when the market is actually ranging. This single change converts the strategy from a money-loser to a money-maker on most crypto pairs.
4. Defining the entry signal
Three conditions:
- RSI(14) crosses up through 30 — momentum has bottomed and is turning.
- ADX(14) < 25 — we're in a non-trending regime where mean reversion has edge.
- Price is above the 200-period SMA — basic trend filter, only buy in the longer-term uptrend.
Together these ensure we're buying a short-term oversold pullback inside a longer-term up-bias, while the medium-term regime is non-trending. That's a real edge — the textbook setup for crypto mean reversion.
5. Exits and risk
Two exits: a target (RSI back above 60, take 50% off; RSI above 70, take the rest) and a stop (ATR-based, K=2.0). Position sized using the ATR formula so dollar risk is constant. No more than one position open per symbol at a time. Daily loss cap at 3% of equity.
strategy:
name: rsi_mean_reversion_btc_4h
symbol: BTC/USDT
timeframe: 4h
indicators:
- { id: rsi, kind: RSI, period: 14 }
- { id: adx, kind: ADX, period: 14 }
- { id: sma200, kind: SMA, period: 200 }
- { id: atr, kind: ATR, period: 14 }
rules:
entry:
type: AND
children:
- { type: cross_above, left: rsi, right: 30 }
- { type: lt, left: adx, right: 25 }
- { type: gt, left: close, right: sma200 }
exit:
type: OR
children:
- { type: cross_above, left: rsi, right: 60, partial: 0.5 }
- { type: cross_above, left: rsi, right: 70 }
risk:
size:
method: atr
risk_pct: 0.75
atr_mult: 2.0
daily_cap:
loss_pct: 3.0
walk_forward:
in_sample_months: 12
out_of_sample_months: 3
mode: rolling
objective: sharpe6. Backtest and walk-forward
A single in-sample backtest tells you almost nothing. The right approach is:
- Run a baseline backtest on the full historical period. Note Sharpe, max drawdown, MAR. This is the optimistic upper bound.
- Run a walk-forward with 12-month in-sample / 3-month out-of-sample windows, rolling. Concatenate the out-of-sample returns. Compute the same stats on the stitched curve.
- Compare. Expect 30-60% Sharpe degradation. If the walk-forward Sharpe is well below 0.5, the strategy is probably noise.
- Slice the stitched curve by regime. If 100% of the P&L came from one year, the strategy is not robust.
7. Paper-trade for a month
Before risking capital, run the strategy in paper for at least 30 days. The paper engine on this platform uses live exchange prices and fills against the same simulator as the backtester, so the only thing you're testing is the gap between historical and current regime — and your own ability to leave the bot alone.
8. Promote to live (carefully)
When you do go live, start at a fraction of the size you backtested. A common discipline: 25% of intended size for the first month, 50% for the second, full size in month three if behaviour matches paper. This catches regime shifts and silent infrastructure bugs without blowing up the account.
9. When it breaks
Mean-reversion strategies break in trending regimes. When BTC goes parabolic, the RSI sits at 80 for weeks and your strategy goes flat — which is fine. The danger is when the strategy keeps trying to buy oversold conditions in a downtrend: ADX rises, your filter should disable the signal, but the filter has lag. Watch for the strategy taking losses three trades in a row — that's the signature of a regime shift, not random bad luck, and you should pause and re-validate before adding more.
10. Takeaways
- RSI alone is not an edge. RSI gated on a regime filter and a trend filter can be.
- Walk-forward before live. No exceptions.
- Paper for at least a month before risking capital.
- Promote gradually. Watch for three-loss strings as a regime canary.
Next steps
The full set of available indicators is in the indicators reference; the GUI for building the YAML above is in the strategy designer; and the walk-forward harness is documented at /docs/walk-forward. Or skip ahead and sign up — the free tier lets you build and backtest one strategy with no time limit.
Try it on your own data
Every concept above is implemented in the platform. Backtest, walk-forward, paper-trade, then promote to live — same rule set, all stages.