
Chapter 2 | 3 min read
Testing Your Strategy (Backtesting)
You’ve built your strategy. Now comes one of the most important steps in algo trading: Backtesting — simply put, testing your logic on past market data.
Think of it like a dress rehearsal before the live show. It tells you: “If I had used this strategy earlier, how would it have performed?”
Let’s break it down step by step.
Why Backtest?
Before you risk real money, you need answers like:
- Does this strategy actually work?
- How many trades does it take in a day/week?
- Is it mostly profitable or loss-making?
- What’s the biggest loss it ever took?
Backtesting gives you a clear picture — without any real-world risk.
What You’ll Need:
- Access to historical data (this is usually built into the platform you use)
- A strategy builder (dropdown-based or rule-based interface)
- Defined logic (from Chapter 3.1)
Steps to Backtest
-
Choose Your Symbol
Example: Pick a stock or index like Nifty, Bank Nifty, or a stock you follow. -
Select the Timeframe
For intraday: 5-min or 15-min For swing: Daily or hourly charts -
Set Entry & Exit Rules
Example:
a. Entry: When 5 EMA crosses above 20 EMA b. Exit: 2% profit or 1% stop-loss OR 5 EMA crosses below 20 EMA
-
Set Capital Allocation Let’s say ₹10,000 per trade. This helps calculate profits/losses.
-
Run the Backtest The system will scan the historical data, simulate all matching trades, and give you results.
Key Metrics to Watch
After running the backtest, look at:
- Total Trades: How many were taken?
- Win Rate: Percentage of winning trades
- Average Profit/Loss: Per trade result
- Maximum Drawdown: Worst loss from peak to bottom
- Profit Factor: Total profit ÷ Total loss (above 1 is good)
These numbers help you decide whether to:
- Keep the strategy as-is
- Modify the entry/exit
- Ditch it completely
Common Mistakes to Avoid
- Don’t overfit the strategy just to get perfect past results. That’s called curve fitting and it often fails in real trading.
- Make sure the data used is clean and includes all market conditions — trending, sideways, volatile.
Final Thought:
Backtesting doesn’t guarantee success — but skipping it guarantees trouble.
It’s your safety net, your feedback loop, and your teacher. One step closer to going live with your first algo!
Recommended Courses for you
Beyond Stockshaala
Discover our extensive knowledge center
Learn, Invest, and Grow with Kotak Videos
Explore our comprehensive video library that blends expert market insights with Kotak's innovative financial solutions to support your goals.













