Backtesting is the process of testing a trading strategy using historical market data to see how it would have performed in the past. Think of it as a time machine for your trading ideas.
Before risking real money, you want to know if your trading strategy actually works. Backtesting helps you:
Important: Past performance doesn't guarantee future results. Backtesting shows what would have happened, not what will happen. Always combine backtesting with other analysis and risk management.
The backtesting process follows these steps:
┌─────────────────┐
│ Define Strategy │ (Your trading rules)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Load Historical │ (Past price data)
│ Data │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Execute Trades │ (Simulate buying/selling)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Track Positions │ (Monitor profit/loss)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Calculate │ (Analyze performance)
│ Metrics │
└────────┬────────┘
│
▼
┌─────────────────┐
│ View Results │ (Make decisions)
└─────────────────┘A strategy is a set of rules that determine when to buy and sell. It can be as simple as "buy when price drops 5%, sell when it rises 10%" or as complex as combining multiple technical indicators, fundamental data, and sentiment analysis.
Signals are specific points where your strategy triggers an action. An entry signal tells you when to buy, and an exit signal tells you when to sell.
Rules that protect your capital:
Key measurements to evaluate your strategy:
Stratify provides 4 template strategies to get you started. Each represents a different trading philosophy:
Follows market trends by buying when prices are rising and selling when they're falling. Uses indicators like RSI and moving averages to identify momentum.
Best for: Trending markets, riding strong price movements
Buys when prices drop below average and sells when they return to normal. Based on the idea that prices eventually revert to their mean.
Best for: Range-bound markets, buying dips in quality stocks
Captures new trends by buying when price breaks above recent highs with strong volume. Aims to catch the start of major moves.
Best for: Capturing explosive moves, early trend identification
Combines social media sentiment with technical analysis. Trades when positive buzz aligns with favorable technical signals.
Best for: Event-driven trading, meme stocks, news-sensitive names
Avoid these mistakes when backtesting:
Tweaking parameters until they perfectly match historical data. This creates a strategy that only works on past data, not future markets. Test on multiple time periods and stocks.
Using information that wouldn't have been available at the time. For example, using tomorrow's closing price to make today's decision. Stratify prevents this automatically.
Forgetting about commissions, slippage, and spreads. A strategy with many trades might look profitable but lose money after costs. Always include realistic costs.
Testing on just a few months or only during bull markets. Test on at least 2-3 years including different market conditions (bull, bear, sideways).
Stratify comes with 4 pre-built template strategies so you can start backtesting immediately. No coding required - just configure, test, and analyze.
Run Your First Backtest→When running a backtest, you can configure numerous parameters to match your trading style:
Choose which stocks to test:
Test period selection:
Bar size for analysis:
1d - Daily bars (recommended for swing trading)1h - Hourly bars (day trading strategies)15m - 15-minute bars (active trading)1w - Weekly bars (long-term strategies)Starting account balance for the simulation. Default: $100,000. This affects position sizing and number of shares per trade.
Maximum loss per trade before automatic exit:
Target profit level for automatic exit:
How much capital to risk per trade:
Limit concurrent open positions to control overall portfolio risk. Example: max 5 positions means at most 5 stocks held simultaneously.
Dynamic stop loss that moves up as price increases, locking in profits. Example: 1% trailing stop means stop loss follows 1% below highest price reached.
Broker fees per trade. Modern brokers: $0. Traditional: $5-10 per trade or 0.005% per share. Default: 0.1%
Difference between expected and actual fill price. Typical: 0.05-0.2%. More for illiquid stocks. Default: 0.1%
Important: Always include realistic transaction costs. A strategy with 100 trades/year and 0.2% total costs loses 20% to fees alone!
After a backtest completes, you'll see comprehensive performance analytics:
%Overall profit/loss: (Final Equity - Initial Capital) / Initial Capital × 100
Example: $100k → $115k = +15% return
%/yearAnnualized return accounting for compounding. More accurate than simple annualized return.
Good: >10%/year • Great: >15%/year
%Largest peak-to-trough decline. Measures worst-case loss you'd experience.
Good: <15% • Acceptable: 15-25% • High Risk: >30%
%Standard deviation of returns. Measures consistency of performance.
Low: <15% • Medium: 15-30% • High: >30%
ratioRisk-adjusted returns: (Return - Risk-free Rate) / Volatility. Higher is better.
Poor: <1 • Good: 1-2 • Excellent: >2
ratioLike Sharpe but only penalizes downside volatility. Better measure for asymmetric strategies.
Typically 20-50% higher than Sharpe ratio
countNumber of complete buy-sell cycles. More trades = more commission costs but also more opportunities.
%Percentage of profitable trades. Winning Trades / Total Trades × 100
Good: >50% • Note: Can be profitable with <50% win rate if winners are larger than losers
ratioTotal gains / Total losses. Must be >1.0 to be profitable.
Acceptable: 1.2-1.5 • Good: 1.5-2.0 • Excellent: >2.0
daysHow long positions are held on average. Helps classify strategy type (day trading vs swing vs position).
Stratify provides multiple charts to understand strategy performance:
Shows account value over time. Key insights:
Shows distance from peak equity. Highlights:
Grid showing returns for each month. Quickly spot seasonality patterns and consistent/inconsistent months.
Histogram of P&L per trade. Shows if you have many small wins/losses or few large ones.
Possible causes:
Solutions: Relax parameters, extend date range, reduce position size.
Check:
Try: Different symbols, different time periods, adjusting risk parameters.
Causes:
Solution: Check symbol's listing date, try different symbols, use forward-fill option in settings.
Warning signs:
Likely: Look-ahead bias, overfitting, or missing transaction costs. Review strategy logic and costs.
Step-by-step tutorial for beginners with screenshots and examples.
Create your own trading strategies from scratch.
Complete guide to all 30+ performance metrics with formulas.
Start backtesting strategies now.