What is algorithmic trading, and why backtest?
Algorithmic trading is the practice of executing trades based on pre-defined, rule-based logic rather than discretionary judgment. Those rules might come from a technical pattern, a statistical relationship, or a machine learning model. Whatever the source, the discipline is the same: define entries, exits, and risk in code, then let the system run.
Why backtesting beats opinion
Markets are adversarial and noisy. A strategy that “feels right” can lose money for years before regressing to its mean. A backtest forces a clean answer to one question: across the chosen period, did this rule make money after costs? It does not guarantee tomorrow’s P&L, but it filters out a large fraction of bad ideas at near-zero cost.
Common pitfalls to avoid
- Overfitting. Tuning a strategy until it looks perfect on past data almost always destroys forward performance. Reserve out-of-sample data and resist the urge to peek.
- Survivorship bias. If your dataset only contains companies that exist today, your backtest skips every bankrupt name. Use point-in-time data when it matters.
- Ignoring costs. Slippage, commissions, and bid-ask spreads compound. A strategy with 60 bps of edge per trade is different from one with 5 bps.
- Confusing backtest with live. Backtests assume fills you may not get in size. Treat backtest results as upper bounds, not promises.
Metrics that actually matter
Total return makes a strategy look good or bad. Risk-adjusted metrics tell you whether you can live with it. The four numbers worth memorizing: Sharpe ratio, maximum drawdown, Calmar ratio, and profit factor. A strategy that scores well on all four is rare; a strategy that scores well on none is not worth running.