Products
Platform
Research
Market
Learn
Partner
Support
IPO
Logo_light
Module 3
Building your First Algo
Course Index

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.

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.

  • 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)
  1. Choose Your Symbol
    Example: Pick a stock or index like Nifty, Bank Nifty, or a stock you follow.

  2. Select the Timeframe
    For intraday: 5-min or 15-min For swing: Daily or hourly charts

  3. 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

  1. Set Capital Allocation Let’s say ₹10,000 per trade. This helps calculate profits/losses.

  2. Run the Backtest The system will scan the historical data, simulate all matching trades, and give you results.

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
  • 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.

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!

Is this chapter helpful?
Previous
Setting a Simple Strategy
Next
Do You Really Need to Code?

Discover our extensive knowledge center

Explore our comprehensive video library that blends expert market insights with Kotak's innovative financial solutions to support your goals.