STRATEGY TESTING GUIDE

How to Backtest a Trading Strategy Before Risking Real Money

AH

Anil Hanegave, Founder, Trading Direction
Professional trader, investor and trading educator – 9+ years of market experience – published trading author – 21,000+ students trained
Award Winning Mentor

Quick Answer: To backtest a trading strategy, write fixed rules for Entry (A), confirmation, Stop Loss (B) and Target (C), apply them to several years of past data, record every trade with costs, and then study expectancy, drawdown and the longest losing streak before you use real money. A backtest shows how rules behaved in the past. No outcome is assured.

Definition: Backtesting (purane data par rules ki jaanch) means applying a fixed set of trading rules to historical prices and recording what every trade would have returned.

Most traders learn a setup from a video, try it for three days on a live account and then decide it does not work. That is an expensive way to test an idea. When you backtest a trading strategy first, past charts do the teaching and your account does not pay the fee. I teach this habit to my students and follow it myself.

The stakes are real. Press reports of SEBI studies say about 91% of individual F&O traders had net losses in FY25 and 87.7% in FY26. Please verify the latest figures on the official SEBI site. Backtesting does not remove that risk, but it forces you to know your rules before the market tests you.

What Is Backtesting and Why Does It Matter?

Backtesting means running your exact trading rules on past price data to see how they would have behaved. It shows win rate, losing streaks, drawdown and costs before you risk any money. It cannot predict the future, so use it to reject weak ideas, not as proof that a strategy will work.

A backtest answers three practical questions. Do the rules earn more than they lose after costs? How long can a losing streak run? Can your account, and your mind, survive that streak? If you cannot answer these with numbers, you are not trading a strategy yet. You are trading a hope.

Backtesting uses past data. Forward testing (aage ke live data par jaanch) uses data the rules have never seen. You need both, in this order: backtest, forward test, then real size. If you want the chart logic behind rules like these, my trading books explain it step by step.

How Do You Backtest a Trading Strategy Step by Step?

Write fixed rules, choose one market and timeframe, test on several years of data, log every trade with costs and then study expectancy and drawdown. Work bar by bar so you never use information that did not exist at that moment. Only then move to forward testing.

  1. Write the rules on one page. Entry (A), confirmation, Stop Loss (B), Target (C), position size and a no-setup condition. If a rule needs “feel”, it cannot be tested.
  2. Pick one market, timeframe and data window. For example NIFTY on a 15-minute chart. Include trending, sideways and volatile phases. There is no official minimum, but a window of only a few weeks tells you very little.
  3. Choose a method. Manual testing with a bar replay feature, a coded test in Pine Script or Python, or a simple spreadsheet. Beginners should start manually, because you learn chart logic while you click through candles.
  4. Log every trade. Date, entry, stop, target, exit, result in R and a short note. Include the losers and the trades you wanted to skip.
  5. Add costs and slippage. Brokerage, STT, exchange charges, GST and the gap between your planned and actual price. Check current charges on your broker’s and NSE’s official pages.
  6. Review the numbers. Expectancy, maximum drawdown, longest losing streak and trade count. Do not judge by win rate alone.
  7. Forward test. Paper trade or use the smallest size on new data before you scale up.
Flow diagram of seven steps to backtest a trading strategy1. Write rules2. Pick market, data3. Choose method4. Log every trade5. Add costs6. Review numbers7. Forward testFail a step? Fix the rules,then restart from step 1.
Seven-step backtesting process (illustrative)

What Does a Backtest Look Like? A Worked NIFTY Example

Take one rule set, apply it to 40 trades and calculate the result before and after costs. In the illustrative example below, the same 40 trades show Rs 16,000 before costs but only Rs 4,000 after costs. That gap is why every backtest must include costs.

All figures here are illustrative and simplified. I assume every winner reaches its full target, every loser hits its full stop and Rs 300 covers costs and slippage per trade. Greeks are ignored, so treat this as index points on a chart. Here is the rule card:

ElementRule (illustrative)
Entry (A)15-minute candle closes above the previous day high, at 24,500
ConfirmationPrice above the CPR and futures volume above the last five-candle average
Stop Loss (B)40 points below entry, at 24,460
Target (C)80 points above entry, at 24,580
Reward to Risk Ratio1 : 2 (a teaching guideline; there is no official minimum)
Position sizingRisk Rs 2,000 per trade ÷ 40 points = 50 units. Check the current NSE lot size and round to valid lots.
No-setup conditionNo close above the previous day high by 1:00 pm means no trade
When NOT to tradeScheduled big events when you cannot define the stop, or when one lot risks more than your Rs 2,000 limit

Here 1R means the Rs 2,000 you risk per trade. The chart below draws the levels to scale.

Annotated candlestick chart showing Entry A, Stop Loss B and Target C with a Reward to Risk Ratio of 1 to 2Entry (A) 24,500Stop Loss (B) 24,460Target (C) 24,580Previous day high 24,495Reward 80 ptsRisk 40 ptsReward to Risk Ratio = 80 : 40 = 1 : 2Entry candle
Illustrative NIFTY levels drawn to scale: Entry (A), Stop Loss (B), Target (C) (illustrative)

Now the 40-trade record: 16 winners and 24 losers, a 40% win rate.

MeasureCalculationResult
Gross gains16 × Rs 4,000Rs 64,000
Gross losses24 × Rs 2,000Rs 48,000
Result before costsRs 64,000 − Rs 48,000Rs 16,000
Costs and slippage40 × Rs 300Rs 12,000
Result after costsRs 16,000 − Rs 12,000Rs 4,000
Expectancy per trade, before costsRs 16,000 ÷ 40Rs 400 (0.2R)
Expectancy per trade, after costsRs 4,000 ÷ 40Rs 100 (0.05R)
Gain-to-loss factor, before costsRs 64,000 ÷ Rs 48,0001.33
Gain-to-loss factor, after costsRs 64,000 ÷ (Rs 48,000 + Rs 12,000)1.07
Longest losing streak (7 trades)7 × (Rs 2,000 + Rs 300)Rs 16,100, or 3.2% of an assumed Rs 5,00,000 account
Bar chart of gross gains, gross losses, costs and result after costs for 40 illustrative tradesRs 64,000Gross gainsRs 48,000Gross lossesRs 12,000CostsRs 4,000Result after costs40 illustrative trades: where the gains go
Rs 64,000 gross gains less Rs 48,000 gross losses less Rs 12,000 costs leaves Rs 4,000 (illustrative)

Take Vivek, an illustrative student. His setups looked like clean 1:2 trades, so he felt ready. After adding costs the edge shrank to 0.05R per trade, and a seven-trade losing streak would cost him 3.2% of his account. He did not go live. He tested a stricter confirmation rule instead. That is a backtest doing its job.

Which Backtest Numbers Matter Most?

Expectancy, maximum drawdown and the longest losing streak matter most, with the trade count as a trust check. A high win rate alone says little, because the average win and average loss decide the result.

NumberWhat it tells youHow to get it
Expectancy (har trade ka ausat result)Average result per trade; it must stay above zero after costs(Win rate × average win) − (loss rate × average loss)
Gain-to-loss factorHow much you gain for each Rs 1 you loseTotal gross gains ÷ total gross losses plus costs
Maximum drawdown (capital mein girawat)Deepest fall from an account peak to the next lowLargest peak-to-trough drop in the equity curve
Longest losing streakThe pain test for your account and mindCount the longest run of consecutive losers
Trade countHow much to trust the other numbersNumber of completed trades
Average Reward to Risk RatioWhether winners really paid more than losers costAverage win ÷ average loss

There is no official cut-off for a “good” number. Guides disagree on how many trades are enough, and the range you will see runs from about 30 to several hundred. Test, pick one rule such as “expectancy above zero after costs over at least 100 trades”, and stick to it.

What Are the Most Common Backtesting Mistakes?

The most common mistakes are over-fitting the rules, using information the market had not yet shown, ignoring costs, testing too few trades and cherry-picking good days. Each one makes a weak strategy look strong on paper.

MistakeWhy it hurtsPractical fix
Over-fittingTuning settings until the past looks perfect; the rules then fail on new dataUse few rules. If a 40-point stop works, check that 35 and 45 also work
Look-ahead biasActing on a candle before it closes makes results look better than they wereDecide only on closed candles and move bar by bar
Ignoring costsA thin edge disappears, as the example showedSubtract brokerage, taxes, charges and slippage from every trade
Too few tradesA lucky week looks like an edgeCollect a larger sample across different market phases
Cherry-picking daysSkipping ugly days inflates resultsTest every day the rules would have triggered
Changing rules mid-testYou are no longer testing one strategyFreeze the rules, then record a new version separately

What Should You Do After the Backtest?

Split your data, forward test on the part you never touched, then paper trade or use the smallest size for a few weeks. Increase size only if live results stay close to the test within a range you fixed in advance.

A simple split is to build the rules on the first 70% of your data and test them once on the last 30%. If they fail there, do not tweak until they pass. That is fitting again, not testing. Go back to the idea.

Mentor Suggestion: Keep a one-page log for every strategy with the rules, the test period, the key numbers and the date you froze it. Review it every weekend, and change one thing at a time. If you want to see how my students apply this on NIFTY, browse the Trading Direction blog.

Backtest Checklist Before You Trade Live

  • ✅ Rules written on one page, with no “feel” words
  • ✅ Entry (A), Stop Loss (B), Target (C) and Reward to Risk Ratio fixed before testing
  • ✅ Data covers trending, sideways and volatile phases
  • ✅ Costs and slippage included in every trade
  • ✅ Expectancy above zero after costs
  • ✅ Longest losing streak fits inside your risk limit
  • ✅ Forward test planned on unseen data
  • ❌ Changing rules after seeing a bad result
  • ❌ Judging a strategy by win rate alone
  • ❌ Going live with full size on day one

When Should You NOT Trade a Backtested Strategy?

Do not trade a backtested strategy when costs wipe out the edge, when the losing streak is larger than you can bear, or when the market no longer behaves like your test data. In these cases, the numbers are telling you to wait.

  • Expectancy turns zero or negative after costs.
  • The longest losing streak is bigger than your risk limit.
  • You cannot define Stop Loss (B) before entry.
  • Market conditions differ sharply from the data you tested, for example a very different volatility phase.
  • Live results drift outside the range you fixed in advance.
  • You are trading to recover a loss instead of following the rules.

Frequently Asked Questions

How many trades are enough for a backtest?

There is no official number. Guides suggest anything from 30 to several hundred. Pick a rule, such as 100 trades across different market phases, and apply it to every strategy you test.

Can I backtest without coding?

Yes. Use a bar replay feature on your charting platform, click through candles one by one and log each trade in a spreadsheet. Manual testing also teaches chart logic.

Is a backtest enough before using real money?

No. A backtest uses past data only. Add a forward test on unseen data and then start with the smallest size. No outcome is assured at any stage.

How much historical data should I use?

Use enough to cover trending, sideways and volatile phases. There is no official length. Many traders start with two to three years for an intraday rule and then test more.

What is a good win rate?

There is no official number. It depends on the Reward to Risk Ratio. In the example above, a 40% win rate with a 1:2 Reward to Risk Ratio was positive before costs but thin after costs.

Why do live results differ from the backtest?

Common reasons are costs, slippage, emotions, over-fitting and a change in market conditions. This is why forward testing and small starting size matter.

Practical Takeaway

  • Write the rules first, then test. Never test first and write the rules later.
  • Include costs and slippage in every trade, because a thin edge can disappear.
  • Judge by expectancy, drawdown and the longest losing streak, not by win rate.
  • Forward test on unseen data and start with the smallest size.
  • Keep a trade log. Your own data is the best teacher you will ever have.

Learn the Chart Logic Before You Test

If you are new to reading charts, start with the Trading Direction Free Trading Course and build the basics at your own pace.

Join the Free Trading Course

Sharing is Caring

⭐⭐⭐⭐⭐

We’d Love Your Feedback!

Please take a minute to share your review and Submit Rating.

Search ‘Trading Direction’ on Google or Google Maps, then click Write a Review.

https://share.google/JCfFYqYVsAioCacP4

Thank you!

Disclaimer: This article is for education only and is not investment advice. All figures and examples are illustrative. Trading in derivatives carries a high risk of loss, including the whole premium, and no outcome is assured. Trading Direction and the author are not presented as a SEBI-registered investment adviser. Please verify all figures, charges and rules on official sources such as SEBI, NSE and your broker before you act.

Related reading

#Backtesting #TradingStrategy #NIFTY #RiskManagement #TradingBasics #TradingDirection

WA Group 🏹 Live Webinar, Sun

Popular Blogs

Recent Posts

Narrow CPR Stocks for Today: How to Read the List and Actually Trade It Oct 16, 2026
Option Position Size Calculator: Sizing Trades by 3% and 4% Risk Oct 15, 2026
Stop-Loss Calculator: Options, Stock & Commodity Trading Oct 14, 2026
Reward to Risk Ratio Calculator: Know Your Numbers Before You Enter Oct 12, 2026

Explore More

📢 Share this Article