Stock Strategy Backtester

Simulate any of 10 classic trading strategies on 21,000+ symbols. Optimize parameters for maximum return or minimum drawdown.

Daily works for stocks, ETFs, forex, commodities & crypto (Yahoo Finance). Intraday (1H–1m) is crypto only via Binance — use symbols like BTC-USD, ETH-USD, SOL-USD.
Enter a symbol above and click Run Backtest to see results.

How to Backtest a Trading Strategy

Backtesting is the practice of simulating a trading rule on historical price data to estimate how it would have performed. It is the single most important step before risking real capital on a discretionary or rule-based system. A well-designed backtest answers three questions: does the edge exist?, how painful is the drawdown?, and is the return worth the risk?

This calculator runs entirely in your browser. Your symbols, parameters, and results never leave your device. Data is fetched from Yahoo Finance (21,000+ symbols covering US stocks, ETFs, ADRs, Indonesian stocks on IDX, cryptocurrencies like BTC-USD, forex pairs like EURUSD=X, and commodities).

The 10 Strategies Explained

1. SMA Crossover

Buy when the fast simple moving average crosses above the slow SMA; sell when it crosses below. A classic trend-following rule. Common choices: 20/50, 10/30, or the famous 50/200 "golden cross".

2. EMA Crossover

Same logic as SMA crossover but with exponential moving averages, which react faster to recent price changes. Often produces more signals (and more whipsaws in choppy markets).

3. RSI Mean Reversion

Buy when the Relative Strength Index drops below the oversold threshold (typically 30); sell when it rises above overbought (typically 70). Works best in range-bound markets; tends to lose money in strong trends.

4. MACD Crossover

Go long when the MACD line crosses above its signal line; exit when it crosses below. MACD combines trend (12/26 EMA difference) with momentum (9-period signal line smoothing).

5. Bollinger Bands — Mean Reversion

Buy when the price touches or breaches the lower band (2 standard deviations below the 20-day SMA); sell when it reaches the upper band. Profits from short-term extremes reverting to the mean.

6. Bollinger Bands — Breakout

Opposite of mean reversion: buy when price breaks above the upper band (strength signal), sell when it closes back inside. Works in trending regimes, fails in choppy ones.

7. Donchian Breakout

Buy when price makes a new N-day high; exit when it makes a new N-day low. Popularized by the "Turtle Traders" (Richard Dennis, 1983) with a 20/10 variant. Simple but surprisingly robust.

8. Golden Cross

The most famous long-term trend filter: buy when the 50-day SMA crosses above the 200-day SMA, sell when it crosses below ("death cross"). Rare signals, but each one tends to capture major bull/bear phases.

9. ATR Trailing Stop

A dynamic stop-loss that follows price at a fixed multiple of Average True Range. Re-enters on breakouts above the prior stop level. Balances giving the trend room to breathe with cutting losses quickly.

10. Buy & Hold (Baseline)

Not a strategy, but the benchmark every active system must beat. If your MACD crossover delivered 9% CAGR but buy-and-hold on the same asset returned 12%, your model destroyed value.

Interpreting the Metrics

Parameter Optimization — Use With Caution

The Optimize button runs a grid search over reasonable parameter ranges and reports the top 10 combinations. This is powerful but dangerous. Curve-fitting to historical data is the #1 way retail traders delude themselves. A rule of thumb: if you optimize 50 parameter combinations on 5 years of data, at least one will look spectacular by pure chance.

Professional practice: split data into an in-sample window (say, first 70%) for optimization and an out-of-sample window (remaining 30%) for validation. A strategy that dominates in-sample but collapses out-of-sample is overfit and should be discarded. You can manually approximate this by running a 5Y backtest to find parameters, then re-running with a 10Y range to see if the edge persists on older data.

Limitations of This Backtester

Transparent assumptions:

Real-world results will be worse than shown here. Use this tool for relative comparison between strategies, not for absolute return forecasting.

Related Tools

Disclaimer

This tool is for educational and research purposes only. It does not constitute investment advice. Past performance is not indicative of future results. Trading involves substantial risk of loss. Always consult a licensed financial advisor before deploying real capital.