Beginner Guide · Chapter 11 of 12

Chapter 11: The Sample Analysis: Backtesting a Trading System

What you will learn

  • Understand why a strategy must be tested over many examples.
  • Write entry and exit rules that another person could reproduce.
  • Measure expectancy, drawdown and other useful statistics.
  • Move from historical testing to simulation and small live size carefully.

Why backtesting matters

Backtesting means applying a complete set of trading rules to historical data and recording what would have happened. It does not prove that the future will match the past. It helps answer a more practical question: Did the idea show a repeatable advantage under different conditions, after realistic costs? Without testing, a trader remembers dramatic winners and forgets ordinary losses. A proper test includes every valid signal in the chosen sample, including losing trades, gaps and difficult periods. The purpose is to replace hope with evidence.

Begin with exact rules

A test cannot be reliable if the rules are vague. Define the market, time frame, trading hours, trend filter, setup, trigger, entry price, stop, target, trailing method, maximum holding period and position-sizing method. Also define how gaps, missing data and transaction costs will be handled. 'Buy a good-looking hammer near support' is not exact. A testable version might require a daily down move of at least three bars, a hammer whose lower shadow is twice its body within 0.5% of weekly S1, and a later close above the hammer high.

Read Economics

A simple long-only test

A beginner can test a basic system on a liquid share or broad ETF. Condition: the three-period pivot average is above the five-period average and both are rising. Setup: price pulls back to the central or first support pivot and forms a doji or hammer. Trigger: a completed close above the setup high. Entry: next open. Stop: below the setup low. First exit: half at two times initial risk. Final exit: below the latest higher swing low or after ten bars. Use at least 50 trades and preferably more. Do not skip an unattractive signal once its outcome is known.

Essential performance measures

Win rate is the percentage of trades that make money. Average win and average loss show the typical size of each outcome. Profit factor is gross profit divided by gross loss. Expectancy estimates the average amount earned or lost per trade. Maximum drawdown is the largest decline from a previous account peak. Also record the longest losing streak, time in the market and total costs. No single number is sufficient. A 75% win rate can lose money if occasional losses are enormous. A 40% win rate can be profitable when winners are much larger than losses.

Expectancy in simple language

Expectancy combines win probability and payoff. A basic formula is: (Win rate × Average win) − (Loss rate × Average loss). Suppose 45% of trades win an average of ₹2,400 and 55% lose an average of ₹1,000. The expectancy is (0.45 × 2,400) − (0.55 × 1,000) = ₹530 per trade before costs. If average brokerage, taxes and slippage total ₹180, the adjusted expectancy becomes ₹350. Positive expectancy does not mean every trade earns ₹350; it means the average may approach that value over a large sample if the future resembles the test.

Drawdown and losing streaks

Drawdown measures the fall from an account peak to the next low. If equity rises to ₹1,20,000 and later falls to ₹1,05,000 before making a new high, the drawdown is ₹15,000 or 12.5%. Losing streaks happen even in profitable systems. A strategy with a 45% win rate can easily have six or more losses in a row. Testing reveals this possibility and helps choose conservative risk. If six planned losses would cause panic or force the account to stop, the position size is too large.

Test different market conditions

A system may succeed in a strong trend and fail in a range. Divide results into bullish, bearish and neutral conditions. Also examine high-volatility and low-volatility periods, rising and falling sectors, and different years. The goal is not to find one rule that wins everywhere. The goal is to learn where the method has an advantage and where it should be reduced or avoided. Market-condition filters must be defined objectively so that they can be used in live trading.

Avoid overfitting

Overfitting happens when rules are adjusted so closely to past data that they describe accidents rather than durable behaviour. A trader may change an oscillator setting from 14 to 13, add a special day-of-week rule and exclude several losses until the historical curve looks perfect. The resulting system often fails on new data. Prefer simple rules with a logical market reason. Keep part of the data out of development. This is called out-of-sample testing. A modest result that survives new data is more useful than a beautiful result created by endless adjustments.

From test to live trading

After historical testing, trade the rules in simulation or paper trading. This forward test reveals data delays, platform issues and emotional hesitation. Require a minimum sample and a high level of rule compliance before using money. Then begin with the smallest practical size. Live results will differ because of slippage, missed orders and human behaviour. Compare them with the expected range, not with the best historical month. Increase size only after a meaningful sample shows that execution and performance remain acceptable.

MetricWhat It AnswersWhy It Matters
Win rateHow often does the system win?Must be viewed with payoff size
Average win/lossHow large are typical outcomes?Shows reward versus risk
ExpectancyWhat is the average result per trade?Combines probability and payoff
Profit factorHow much gross profit per rupee lost?Summarizes overall efficiency
Maximum drawdownHow bad was the largest decline?Guides capital and emotional fit
Longest losing streakHow many losses in sequence?Guides size and discipline

Practice exercise

Write one simple setup in exact language and test at least 50 historical examples. Reserve the final 20% of the date range for out-of-sample testing. Record every entry, stop, exit, cost and market condition. Calculate win rate, average win, average loss, expectancy, profit factor, maximum drawdown and longest losing streak. Then complete 20 simulated trades without changing the rules.

Before you move on

  • Every rule is precise enough for another person to reproduce.
  • I included all valid signals and realistic transaction costs.
  • The sample covers trends, ranges and different volatility conditions.
  • I separated development data from out-of-sample data.
  • I will use simulation and minimum size before increasing exposure.

About the author

Amit Khari
Amit KhariContributor, LiveWorldMarket

NISM-Series-X-A Investment Adviser Level 1 examination completed

Amit writes about Indian equity markets, technical analysis, macro themes and the day-to-day mechanics of trading, with a focus on making the flow of global markets legible for retail investors. He has completed the NISM-Series-X-A Investment Adviser Level 1 examination.

Advertisement
Advertisement