Skip to content

    Backtesting Trading Strategies

    Quick answer

    Backtesting applies trading rules to past data. Build a test with realistic execution, costs and unseen periods, then inspect what the results cannot prove.

    31 January 2026
    13 min read
    2,401 words

    Backtesting means applying written trading rules to historical data and calculating the trades those rules would have produced. A useful test specifies the information available at each decision, when orders could execute, position size and costs. The result is a simulation under those assumptions. It cannot establish future profit, and a smooth historical chart can conceal errors or rules selected to fit the past.

    Write a testable rule before opening the results

    A strategy needs an entry condition, an exit condition and a sizing rule. Phrases such as strong momentum or a clean breakout are not enough unless another person could apply them consistently to the same information.

    Write down the instrument, timeframe, trading session, eligible contracts and order type. Explain whether a condition is confirmed during a candle (a chart’s price bar) or only after it closes. Also decide what happens when data is missing, orders remain unfilled, positions overlap or a contract expires.

    The trading-plan guide can help organise those decisions. Keep the first version and record later changes so an improved result does not hide how many alternatives were tried.

    Suggested fields to record before running a test. Check how your chosen platform handles each one.
    Test-plan fieldQuestion it must answer
    Decision timingWhat information is known when the signal appears?
    Execution timingWhat is the earliest plausible price at which the order can trade?
    Position sizeWhat quantity and cash exposure does each entry create?
    Exit priorityHow are a stop and target handled if both appear reachable?
    CostsWhich fees, spread and execution adjustments are included?
    Evaluation periodWhich history is used to develop rules and which remains untouched?

    Use data that matches the instrument

    A cash-index chart is not an executable option-premium history. An option test needs the actual expiry, strike, type and premiums available at the decision time. If a test substitutes an assumed option response to an index move, label that as a model assumption.

    For futures, check how the data joins successive expiries. A continuous chart can be useful for examining price behaviour while still differing from the contracts actually traded. Record the rollover rule and prices used rather than treating a joined series as an execution ledger.

    For stock tests, inspect how the provider handles splits, dividends, missing bars and changes to the eligible company list. Choosing today’s surviving companies for the entire past can exclude failures or removed names. A result needs the intended historical universe, meaning the securities eligible at the time.

    Keep the data version, source and date range with the test. If a provider revises a series or the strategy uses a different dataset later, the reason for changed results should remain traceable.

    Do not let the strategy see the future

    Look-ahead bias means using information that was unavailable at the simulated decision. A rule that needs a candle’s closing value cannot assume it knew that value at the candle’s opening. A later-published company figure also cannot be used on the earlier period-end date merely because it describes that period.

    TradingView’s documentation describes how historical execution settings can expose final candle values too early. Check the actual signal and execution clocks in your chosen tool. A setting that produces more trades or a better curve is not automatically more realistic.

    A candle’s open, high, low and close do not, by themselves, reveal the full order of prices inside it. When both stop and target could be touched, the backtest needs finer data or an explicit sequencing assumption. Inspect ambiguous trades rather than silently giving every one the favourable outcome.

    Costs can reverse a profitable gross result

    Here is a made-up test summary, not a historical strategy result. Assume 10 closed trades: 4 winners at ₹2,000 gross each and 6 losers at ₹1,000 gross each. Assume ₹300 of total spread, fees and execution adjustments per completed trade. That cost allowance is fictional, not a brokerage quote.

    Illustrative trade outcomes and costs only. No market return, actual tariff or tax rate is represented.
    MeasureExample arithmeticResult
    Gross wins4 × ₹2,000₹8,000
    Gross losses6 × ₹1,000₹6,000
    Gross result₹8,000 − ₹6,000₹2,000
    Assumed total costs10 × ₹300₹3,000
    Net result₹2,000 − ₹3,000−₹1,000

    The example win rate is 40%, and gross profit factor is about 1.33: gross wins divided by gross losses. Yet the net result is negative. Average net result per closed trade is −₹100. The attractive gross ratio does not survive the assumed costs.

    See trading expectancy for average-outcome calculations. Keep gross and net definitions consistent, and avoid subtracting costs again if they are already included in the reported outcomes.

    For an Indian-market historical test, use charges appropriate to the instrument and the simulated date. A current tariff should not silently replace the rates that applied throughout an older test. Personal income tax is a separate calculation and should not be guessed as a universal percentage of every winning trade.

    Indian rules that change between test periods

    A test that runs over several years crosses real rule changes. If you apply today's rules to the whole history, the numbers describe a market that never existed. Check these for every period you test.

    Dates from the NSE circulars and SEBI circular logged in our charges changelog and expiry rules, checked 28 Oct 2026. Confirm each date on the exchange site.
    ItemWhat changedWhy it matters for a test
    Futures STT (securities transaction tax)0.02% to 0.05% of the sell value from 1 Apr 2026The same futures trade costs more after that date
    Options STT0.1% to 0.15% of premium sold from 1 Apr 2026Option sellers' costs rose; test costs by date
    Bank Nifty, FinNifty and Midcap Nifty weekly optionsWeekly series ended in November 2024; they now have monthly expiryA weekly-expiry test on these indices cannot be traded now
    Nifty expiry dayWeekly expiry on Tuesday since 1 Sep 2025Earlier years used other expiry days, so day-of-week rules shift
    Contract sizeExchanges revise lot sizes from time to timeUse the lot size in force on each test date

    Build a small table of rates and lot sizes by date, and make your test look up the right row for each trade. Do not type today's numbers into a single cell. The brokerage and charges guide explains each charge you need in that table.

    Separate development from later evaluation

    Use an earlier period to formulate and compare rules. Then freeze the chosen rules before evaluating a later period that was not used to choose them. Record all the attempted versions, including unsuccessful ones. Looking at the later result and repeatedly retuning the strategy turns that period into development data too.

    A walk-forward process repeats chronological development and later evaluation under a procedure chosen in advance. It can reveal deterioration as conditions change. It does not remove the need to count experiments or prevent an overall method from being selected after seeing its results.

    The research paper The Probability of Backtest Overfitting warns that even familiar holdout methods can be unreliable in investment backtests. An unseen period is a useful safeguard, not a guarantee that the selected strategy has a repeatable advantage.

    A simple walk-forward plan you can follow

    Here is a made-up plan using five years of history, to show how the idea works. The years are examples.

    Illustrative schedule. The period lengths are examples, not a recommendation.
    StepPeriodWhat you do
    1Years 1 to 3Develop rules and compare versions. Keep a list of every version tried.
    2Year 4Run the frozen rules once, with no changes. Record the result, good or bad.
    3Year 5Only if you decide beforehand to repeat the process: re-develop on years 2 to 4, then run the frozen rules on year 5.
    4After step 3Stop changing the rules. Watch how they behave on new data.

    The important discipline is writing the plan before you see the results. If year 4 looks poor and you go back to change the rules, year 4 has become development data, and you no longer have an unseen test.

    Inspect trades as well as headline metrics

    • Review the largest losses, long losing sequences and concentration in a small number of wins.
    • Read how the account value changed throughout the test, including open-position losses where relevant.
    • Separate different market conditions and retain weak periods in the report.
    • Try reasonable changes to execution assumptions and inspect whether the conclusion depends on perfect prices.
    • Check whether required cash and margin could have supported the simulated positions.
    • Compare a sample of entries and exits with the underlying records.

    A drawdown is a decline from an earlier account peak. The largest observed historical decline is not a maximum possible future loss. A short sample or an unusually favourable period can understate how difficult the strategy might be to hold.

    Counting your experiments and sample size

    Each version of a rule that you try is an experiment. If you test many variations on the same history, some will look good by chance. Keep a simple count. A strategy that was the best of 50 variations deserves far less trust than one that was written down once and tested once. Say so in your notes, so you do not forget it later.

    On sample size, there is no magic number. A test with only a few trades, or with trades bunched into one short market phase, says very little. More trades spread across rising, falling and sideways markets give a fuller picture, but they still do not guarantee anything about the future.

    Choose a method by what it can represent

    Manual review can work when decisions depend on chart context, provided future candles remain hidden and each decision is recorded before advancing. A spreadsheet can make simple rules and arithmetic visible. An automated engine can apply more rules across a larger sample, but its execution and data assumptions still need inspection.

    For example, TradingView distinguishes a strategy that creates simulated orders from an indicator that merely draws values. Its broker emulator has settings for commission, slippage (execution-price differences), price verification and order delay. Read the chosen platform’s documentation; a chart displaying entry arrows is not a complete test by itself.

    Save the actual transaction list alongside the report and rule version. A headline return without the inputs and trades is difficult to reproduce or challenge. A retest should be able to explain why it agrees or differs.

    What to record for every backtest

    • The written rules, with a version number and date.
    • Data source, date range and any cleaning you did.
    • The cost and lot-size table used, by date.
    • Entry and exit timing assumptions (next bar open, close, limit price).
    • Number of versions tried before this one.
    • Result with and without costs, plus the largest drawdown and the longest losing run.
    • What the test cannot tell you, written in one or two sentences.

    A spreadsheet is enough to hold this log. The trading journal template guide shows a layout you can adapt, and how to review your trades covers reviewing the live trades afterwards.

    Use new observations to check implementation

    After freezing a version, observe how its rules behave as new information arrives. Compare the recorded signal time, intended order and available prices with what the historical model assumed. This can reveal timing and execution mismatches without claiming that a short forward sample proves profitability.

    The distinction is covered in backtest versus live results. OneTradeJournal is a manual trading journal; it does not run backtests or provide market replay. Its trade notes, emotions and plan-deviation fields can help review actual decisions after the test has been performed elsewhere.

    Common backtesting mistakes to avoid

    • Using today's lot size, tax rates or expiry days for old trades.
    • Testing a weekly-expiry rule on an index that no longer has weekly expiry.
    • Assuming a fill at the exact signal price, with no slippage, on a fast move.
    • Treating an index chart as if it were an option-premium history.
    • Changing the rules after seeing the unseen period.
    • Reporting only the best version and forgetting the rest.
    • Skipping a sanity check by hand on a few trades.

    Once you start trading a tested idea, the trades you actually take become the real evidence. Log them with your reasons, stops and whether you followed the plan. OneTradeJournal is a manual journal for that step. It does not run backtests. Compare what you did against what the test assumed, and you will see quickly where the real world differs.

    Backtesting questions

    Sources

    Related Topics

    backtesting strategieshow to backtest trading strategybacktesting Indialook ahead biasbacktesting costs

    Related Articles