Mean Reversion

Bollinger+RSI — Tech

A dual-confirmation mean reversion strategy. Buys only when price falls more than 2 standard deviations below the 20-period mean and RSI confirms oversold (<30). Exits when price reverts to the mean. Fires 5–15 trades/day — precise entries, not noise.

View Backtest
How It Works
1
Compute 20-period Bollinger Bands: mean ± 2 standard deviations from recent prices
2
Compute 14-period RSI (0–100) — measures momentum and oversold/overbought conditions
3
Buy only when price is below the lower band and RSI < 30 — dual confirmation required
4
Sell when price recovers above the middle band (mean reversion complete) or RSI > 70 above upper band
Parameters
bb_period 20
bb_multiplier
rsi_period 14
rsi_oversold 30
symbols AAPL, MSFT, NVDA
shares_per_trade 5
Entry / Exit Logic
bollinger-rsi.js
// Bollinger Bands — mean ± (multiplier × std dev)
function calculateBollingerBands(prices, period, multiplier) {
  const slice = prices.slice(0, period);
  const mean = slice.reduce((a, b) => a + b, 0) / period;
  const variance = slice.reduce((s, p) => s + (p - mean) ** 2, 0) / period;
  const stdDev = Math.sqrt(variance);
  return {
    upper: mean + multiplier * stdDev,
    middle: mean,
    lower: mean - multiplier * stdDev
  };
}

// Signal generator — dual confirmation required to enter
function bollingerRsiSignal(prices, params) {
  const bb = calculateBollingerBands(prices, params.bb_period, params.bb_multiplier);
  const rsi = calculateRSI(prices, params.rsi_period);
  const price = prices[0]; // most recent

  // ENTRY: price below lower band AND RSI oversold — both must fire
  if (price < bb.lower && rsi < params.rsi_oversold) {
    return 'buy';  // Extreme dip + momentum confirmation
  }

  // EXIT: price recovered above middle band (reversion complete)
  if (price > bb.middle) {
    return 'sell'; // Mean reversion done — take profit
  }

  // EXIT: RSI overbought AND above upper band — extended move
  if (rsi > params.rsi_overbought && price > bb.upper) {
    return 'sell'; // Overbought — exit aggressively
  }

  return 'hold'; // Waiting for setup
}
Backtest Results (180 days, $50k)
Total Return
Win Rate
Max Drawdown
Sharpe Ratio
Total Trades
Final Value
Mean Reversion

RSI Reversion — Growth

A contrarian strategy using the Relative Strength Index. When RSI drops below 30, the stock is oversold — buy the dip. When RSI rises above 70, it's overbought — take profits. Works best on volatile growth stocks that oscillate between extremes.

View Backtest
How It Works
1
Calculate 14-period RSI from price changes (0-100 scale)
2
Buy when RSI drops below 30 (oversold — market panic = buying opportunity)
3
Sell when RSI rises above 70 (overbought — euphoria = take profits)
4
Hold when RSI is between 30-70 (neutral zone — no action)
Parameters
rsi_period 14
oversold 30
overbought 70
symbols TSLA, GOOGL, AMZN
shares_per_trade 10
initial_capital $50,000
Entry / Exit Logic
rsi-reversion.js
// Relative Strength Index — measures momentum (0-100)
function calculateRSI(prices, period) {
  const changes = [];
  for (let i = 1; i < period + 1; i++) {
    changes.push(prices[i-1] - prices[i]);  // newest first
  }

  let avgGain = 0, avgLoss = 0;
  for (const c of changes) {
    if (c > 0) avgGain += c;
    else avgLoss += Math.abs(c);
  }
  avgGain /= period;
  avgLoss /= period;

  if (avgLoss === 0) return 100;
  const rs = avgGain / avgLoss;
  return 100 - (100 / (1 + rs));  // RSI formula
}

// Signal generator — runs on every tick
function rsiSignal(prices, params) {
  const rsi = calculateRSI(prices, params.rsi_period);  // 14

  if (rsi < params.oversold)   return 'buy';   // RSI < 30 → oversold
  if (rsi > params.overbought) return 'sell';  // RSI > 70 → overbought
  return 'hold';                            // 30-70 → neutral
}
Backtest Results (180 days, $50k)
Total Return
Win Rate
Max Drawdown
Sharpe Ratio
Total Trades
Final Value

Run these strategies on paper money

No risk. Real market data. Watch the AI execute trades autonomously while you learn.

Start Paper Trading

Paper trading only — no real money at risk. Past backtest performance does not guarantee future results.