Backtesting Trading Strategies
Backtesting applies trading rules to past data. Build a test with realistic execution, costs and unseen periods, then inspect what the results cannot prove.
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.
| Test-plan field | Question it must answer |
|---|---|
| Decision timing | What information is known when the signal appears? |
| Execution timing | What is the earliest plausible price at which the order can trade? |
| Position size | What quantity and cash exposure does each entry create? |
| Exit priority | How are a stop and target handled if both appear reachable? |
| Costs | Which fees, spread and execution adjustments are included? |
| Evaluation period | Which 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.
| Measure | Example arithmetic | Result |
|---|---|---|
| Gross wins | 4 × ₹2,000 | ₹8,000 |
| Gross losses | 6 × ₹1,000 | ₹6,000 |
| Gross result | ₹8,000 − ₹6,000 | ₹2,000 |
| Assumed total costs | 10 × ₹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.
| Item | What changed | Why it matters for a test |
|---|---|---|
| Futures STT (securities transaction tax) | 0.02% to 0.05% of the sell value from 1 Apr 2026 | The same futures trade costs more after that date |
| Options STT | 0.1% to 0.15% of premium sold from 1 Apr 2026 | Option sellers' costs rose; test costs by date |
| Bank Nifty, FinNifty and Midcap Nifty weekly options | Weekly series ended in November 2024; they now have monthly expiry | A weekly-expiry test on these indices cannot be traded now |
| Nifty expiry day | Weekly expiry on Tuesday since 1 Sep 2025 | Earlier years used other expiry days, so day-of-week rules shift |
| Contract size | Exchanges revise lot sizes from time to time | Use 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.
| Step | Period | What you do |
|---|---|---|
| 1 | Years 1 to 3 | Develop rules and compare versions. Keep a list of every version tried. |
| 2 | Year 4 | Run the frozen rules once, with no changes. Record the result, good or bad. |
| 3 | Year 5 | Only if you decide beforehand to repeat the process: re-develop on years 2 to 4, then run the frozen rules on year 5. |
| 4 | After step 3 | Stop 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
- TradingView: simulation and bias limitations (read 16 October 2026).
- TradingView: execution assumptions; strategy report FAQ (read 16 October 2026).
- Bailey and co-authors: backtest overfitting (read 16 October 2026).
Related Topics
Related Articles
Free Trading Journal India: What You Can Log
Start a free trading journal in India with one trade per day per market. Learn what to record, how to check net results and which AI features require payment.
Trading Journal App India: Browser and Phone Guide
Use OneTradeJournal in a phone or computer browser or from the home screen. See what to look for in a trading journal app, manual entry, exports and privacy.
Trading Journal Excel vs App: Compare the Work
Compare an Excel trading journal with OneTradeJournal for manual logging, formulas, reports and exports, and test both on the same five-trade example.
Intraday Trading Journal: Copyable Session Template
An intraday trading journal template with fields, tags, a daily loss rule and a time-of-day review. Includes a worked options cost example. Copy and print it.
Trading Journal for Beginners in India: First Entry
Start a trading journal as a beginner in India: why it helps, a 5-step setup, a sample entry in rupees and what to check after your first 20 trades.
Trading Journal Template India: Excel and Sheets Build Guide
Free trading journal Excel for Indian equity and F&O: download the .xlsx with P&L, R-multiple and monthly summary formulas, or build your own in Sheets.
The trading journal for Nifty, Bank Nifty and Indian F&O. Track your trades, spot patterns, build discipline.
- Log one trade a day by hand, on purpose
- AI mentor finds your repeat mistakes
- Behavioural analytics catch tilt early
- Trading calendar with P&L heatmap
- Pre-trade checklist flags risks
Yearly ₹3,499 · No broker credentials