Backtesting Your Strategy
Testing Before You Trade
Backtesting is the process of applying your trading strategy to historical price data to see how it would have performed in the past. It is the closest thing to a "practice run" before risking real money.
Why Backtest?
Before committing your hard-earned KES to a technical strategy, you want to know:
- Does it actually work? — A strategy that sounds good in theory may produce poor results in practice.
- What is the win rate? — What percentage of trades are profitable?
- What is the average profit vs average loss? — Even a 40% win rate works if winners are much larger than losers.
- What is the maximum drawdown? — The largest peak-to-trough decline in your account. Can you stomach it?
How to Backtest on the NSE
- Define your rules — Be specific. For example: "Buy SCOM when the 12-day EMA crosses above the 26-day EMA and RSI is below 50. Sell when the 12-day EMA crosses below the 26-day EMA."
- Gather historical data — Use Stockr's historical charts or download data from the NSE.
- Apply the rules — Go through the historical data and record every buy and sell signal your strategy would have generated.
- Track results — For each trade, record the entry price, exit price, profit or loss, and holding period.
- Calculate metrics — Win rate, average profit, average loss, total return, maximum drawdown.
What to Track
- Total number of trades — At least 30-50 trades for statistical significance
- Win rate — Percentage of profitable trades
- Profit factor — Total profits divided by total losses (aim for above 1.5)
- Maximum drawdown — The largest loss from peak equity
Avoiding Curve Fitting
Curve fitting is the trap of over-optimising your strategy to fit historical data perfectly. A strategy with 15 rules and specific parameter values tweaked to match past performance will almost certainly fail in real trading. Keep your strategy simple with few, robust rules that make logical sense. If your strategy works across different stocks and time periods, it is more likely to work going forward.
A backtested strategy is not a guarantee of future profits. Markets change. But a strategy that has never been tested is just a guess.