Glossary
Backtesting
Last reviewed: 16 September 2026·Tradelyze
Backtesting is running a trading strategy's exact rules on past price data to see how the strategy would have performed. A backtest lists every trade the rules would have taken and tracks the account balance trade by trade. The results are summed into numbers such as win rate. A backtest shows the past, not the future.
In plain English
A backtest is a rehearsal on old prices. The software replays history one price bar at a time, applies your buy and sell rules exactly, and writes down each trade they would have made. A good rehearsal is a reason to keep testing, not proof that the strategy will make money.
What is backtesting?
Backtesting is a way to try trading rules on history before you risk money on them. You write the rules down precisely, run them over past prices, and study the trades they would have taken. Bailey, Borwein, López de Prado and Zhu define a backtest as “a historical simulation of how an algorithmic strategy would have performed in the past.” Their definition comes from the February 2015 paper The Probability of Backtest Overfitting.
The rules have to be exact enough for a computer to follow. “Buy when the closing price crosses over its 20-bar average; exit at 2% profit or 1% loss” can be backtested. “Buy when the trend looks strong” cannot, because the software has no way to decide what strong means.
On TradingView, a Pine Script strategy is backtested by the Strategy Tester. Its broker emulator, the part that simulates orders, runs the script over the chart's historical bars and records every fill. A bar, also called a candle, is one period of price with an open, a high, a low and a close. The steps for running a backtest in the Strategy Tester are on the how to backtest on TradingView page.
Backtesting matters because it is the cheapest way to throw out a bad idea. If rules lost money on years of past prices, paying a prop firm challenge fee to test them live makes little sense. The reverse does not hold: a profitable backtest is where checking starts, not where it ends.
What goes into a backtest, and what comes out?
Every backtest takes the same four inputs and produces the same three kinds of output, whichever platform runs it. The inputs are:
- Rules: when to enter, when to exit, where the stop-loss sits, and how large each position is.
- Price data: the open, high, low, close and volume of every bar, often shortened to OHLCV. The data must match the instrument and timeframe the rules are meant to trade.
- Costs: commission, which is the broker's fee per trade, and slippage. Slippage is the gap between the price a rule asked for and the price the order actually got.
- Starting capital: the account balance the test begins with, which percentage returns and drawdowns are measured against.
The outputs of a backtest are:
- A trade list: every entry and exit, with its date, price and profit or loss.
- An equity curve: the account balance plotted after each trade or bar. A curve that climbs steadily is safer than one that reaches the same end point through deep dips.
- Metrics: summary numbers such as net profit, win rate, profit factor, Sharpe ratio and maximum drawdown. Win rate is the share of trades that made money. Profit factor is gross profit divided by gross loss. The Sharpe ratio is, roughly, average return divided by how much returns swing. A drawdown is a fall in the account from its highest point so far. Maximum drawdown is the largest such fall, usually shown as a percentage of that peak.
Here is a constructed example, not real trading results. A strategy starts with $10,000 and takes 40 trades. Eighteen trades win an average of $300 each, and 22 trades lose an average of $200 each. Expectancy, the average profit or loss per trade, comes out at $25:
= (0.45 × $300) − (0.55 × $200) = $135 − $110 = $25
| Measure | No costs | $20 cost per trade | How it is worked out |
|---|---|---|---|
| Trades | 40 | 40 | 18 winners plus 22 losers |
| Win rate | 45% | 45% | 18 winners ÷ 40 trades, assuming costs turn no winner into a loser |
| Net profit | $1,000 | $200 | (18 × $300) − (22 × $200) = $1,000, then minus 40 × $20 = $800 of costs |
| Expectancy per trade | $25 | $5 | Net profit ÷ 40 trades |
| Return on $10,000 | 10% | 2% | Net profit ÷ starting capital |
In this constructed example, an assumed $20 of commission and slippage per trade cut the profit from $1,000 to $200, four fifths of the result. A backtest run with zero commission and zero slippage is describing a market where trading is free, and no such market exists.
The equity curve of the same constructed example peaks at $11,200 after 20 trades. The curve falls to $10,360 after 28 trades and ends at $11,000. The fall from $11,200 to $10,360 is $840, or 7.5% of the peak, so the maximum drawdown is 7.5% even though the test finished 10% up.
Maximum drawdown is explained in full on the maximum drawdown page, and expectancy on the win rate and expectancy page.
Is backtesting accurate?
Backtesting is accurate in a narrow sense and unreliable in a broad one. A good backtester does the arithmetic correctly on the data and assumptions it is given. Whether those assumptions match real trading, and whether the future will resemble the past, are separate questions no backtest can settle.
Order fills are the first place the assumptions show. By default, a TradingView strategy recalculates only after each bar closes. TradingView's Pine Script documentation says that means “the next tick on which an order can fill is at the open of the following bar.” A rule that fires on a bar's close is filled at the next bar's open, not at the close price the chart shows.
Inside a bar, the simulator cannot see how price really moved, only the open, high, low and close. TradingView's documentation says that when a bar opens closer to its high than its low, the broker emulator assumes price went open, high, low, then close. If a stop-loss and a profit target both sit inside one bar's range, that assumption decides which one filled. TradingView's Bar Magnifier setting uses lower-timeframe bars, when available, to estimate the path more closely.
Another test of accuracy is whether a second backtester reproduces the same trades from the same rules and data. When two trade lists disagree, one of the two runs made different assumptions about data, timezone, settings or fills. Is TradingView backtesting accurate? explains how to compare the two lists trade by trade.
Why do backtests look better than live results?
Backtests usually look better than live trading because nearly every mistake a backtest can make flatters the result. QuantStart's guide Successful Backtesting of Algorithmic Trading Strategies, Part I puts it plainly: “You should always consider a backtest to be an idealised upper bound on the actual performance of the strategy.” Four causes explain most of the gap.
| Cause | What goes wrong | What to check | Source |
|---|---|---|---|
| Optimization bias (curve fitting) | Settings are adjusted until the past looks great, so the best result is partly luck. Bailey and co-authors write that published backtests “almost never declare the number of trials involved in a discovery.” | How many setting combinations were tried, and whether nearby settings also make money. | QuantStart, Part I; Bailey et al., February 2015 |
| Look-ahead bias | The test uses information that did not exist yet when the trade was made. TradingView warns that request.security() with lookahead on and no one-bar offset “will return data from the future on historical bars.” |
Any request.security() call with lookahead = barmerge.lookahead_on. |
QuantStart, Part I; TradingView, Repainting |
| Missing costs | Commission, spread and slippage are left at zero, so every trade is recorded as free. | The commission and slippage fields in the strategy's properties, set to your broker's real fees. | No primary source for a standard cost figure; check your own broker's fees. |
| Optimistic fills | TradingView's broker emulator fills a limit order when price reaches or crosses its level. In a live market, orders already waiting at that price are filled first, so a touch may not fill yours. | Strategies that depend on limit orders filling at the exact top or bottom of a move. | TradingView, Strategies (fill rule); the queue effect has no primary source cited here. |
Campbell Harvey and Yan Liu describe a professional habit in their article Backtesting (The Journal of Portfolio Management, Fall 2015). Harvey and Liu write that “a common practice in evaluating backtests of trading strategies is to discount the reported Sharpe ratios by 50%.” Harvey and Liu call that 50% haircut “only a rule of thumb.” They argue the right discount depends on how many strategies were tested, so treat 50% as a habit, not a law.
QuantStart's guide also lists survivorship bias: testing only on assets that still exist today, which leaves out the ones that were delisted or failed. QuantStart says equities are especially exposed and certain commodities and their futures less so. Survivorship bias matters most for strategies that pick from a basket of stocks, and much less for a single futures or forex chart.
Optimization bias is covered in depth on the overfitting and sample size page. Costs, fills and the other execution differences between a backtest and a real account are covered on the backtest vs live trading page.
Is your backtest too good to be true? Start with the warning signs.
What can a backtest never tell you?
A backtest can never tell you what the market will do next. A backtest replays one stretch of history in the order it happened, so everything the backtest reports depends on that one stretch. Five questions stay open however good the result looks:
- Whether the edge still exists. Markets change. Rules that worked through a trending year can stall in a sideways one, and a backtest has no data from years that have not happened yet.
- How bad luck could have been. A backtest shows one order of wins and losses. The same trades in a different order can produce a deeper drawdown, and Monte Carlo simulation estimates that range.
- Whether you will follow the rules. QuantStart calls this psychological tolerance bias. A long drawdown that looks small on a chart feels very different in a real account, and traders abandon strategies partway through one.
- Whether your orders would fill at your size. A backtest assumes the market took every order at the simulated price, however large the order was.
- Whether a prop firm's rules will stay the same. Firms change their limits. A backtest checked against last year's rules says nothing about this year's.
How is backtesting different from forward testing and paper trading?
Backtesting, forward testing and paper trading differ in when the prices arrive. A backtest runs the rules over prices that already exist, all at once. A forward test freezes the rules and runs them on new prices as they arrive, with no changes allowed. Paper trading is a forward test with simulated orders on a live price feed: real-time fills, no real money.
Walk-forward analysis sits between the two. Walk-forward analysis tests settings on price data the optimizer never saw, but that data is still historical. A common order of evidence runs: backtest, test on unseen data, forward or paper test, then a small live account. That order is a practitioner convention with no single primary source. The backtest vs live trading page explains what each step proves.
My backtest looks good: what should I check next?
A good-looking backtest has earned more checking, not money. Work through these seven checks in order, because each one can end the process early and the cheap checks come first. Before starting, confirm the backtest included commission and slippage; TradingView strategy properties shows where both are set.
- Make sure the backtest can be reproduced. Run the same rules on the same price data and settings in a second backtester, then compare the two trade lists. If the lists disagree, something differs in the data, timezone, settings or fills, and every later number inherits that difference. See is TradingView backtesting accurate?
- Count the trades, then read win rate together with expectancy. Under about 30 trades, a win rate or profit factor rests on too few events to judge. That 30-trade line is a general statistics convention, not a trading-specific finding. With enough trades, check expectancy as well as win rate. A strategy that wins 90% of the time with 1-point wins and 10-point losses still loses 0.1 points per trade: (0.9 × 1) − (0.1 × 10) = −0.1. See how many trades a backtest needs and win rate and expectancy.
- Check the drawdown against what you could survive. By simple arithmetic, a 50% drawdown needs a 100% gain to get back to the peak. A prop firm account can be closed long before that. See maximum drawdown.
- Ask how many settings were tried. The best of 1,000 setting combinations will usually beat the best of 10, even when none has a real edge. More tries give luck more chances. See strategy optimization and parameters versus trials.
- Test on data the settings never saw. Keep part of the history out of tuning and run the frozen settings on it once. Walk-forward analysis repeats that across several windows of history. See in-sample vs out-of-sample and walk-forward analysis.
- Stress the order of the trades. Monte Carlo simulation reshuffles or resamples the same trades many times to show how much deeper the drawdown could have gone. See Monte Carlo simulation.
- Check the prop firm rules you would trade under. Daily loss limits and trailing drawdowns are measured on the worst stretches, not on the final result. Read the worst single day and the deepest dip during a day. See prop firm rules and backtest metrics.
What passing these checks means
No checklist proves a strategy will make money. Passing all seven checks means the backtest has not yet been shown to be wrong. The next evidence has to come from forward testing or paper trading on prices that did not exist when the strategy was built.
The full checklist: how to validate a trading strategy.
How does Tradelyze check a TradingView backtest?
Tradelyze checks a TradingView Pine Script strategy by re-running it from your own files and then testing the result in up to five stages. Tradelyze needs these files, all supplied by you:
- The Pine Script strategy file. Runs use the script's own default settings, so update the defaults if you changed inputs or properties in TradingView before exporting.
- The TradingView trade list CSV, exported from the Strategy Tester. Tradelyze requires this file. Exporting TradingView trades and price data shows how to get it.
- An OHLCV price data CSV for the same instrument and timeframe. Tradelyze holds no market-data license, so it cannot download prices for you.
- Extra timeframe CSVs, only when the script calls
request.security()orrequest.security_lower_tf().
The five stages, in the order a run shows them:
- Baseline Matching. Tradelyze re-runs the strategy with its default settings on Tradelyze's own Pine Script backtester. It compares the trades with your TradingView export and reports Match Rate, Matched, TV Only and BT Only. A mismatch halts the run and offers Continue anyway and Review comparison.
- Optimizing. Tradelyze tries many versions of your strategy's input settings, each one a full backtest, looking for more profit, steadier returns and smaller drops in the account. The best result is chosen on the same prices it is scored on, so treat it as the most optimistic number in the report.
- Walkforward Analysis. By default, Tradelyze uses 2 rolling windows, meaning each window starts later in history than the one before, and picks the walk-forward method for each run automatically. The card shows a PASS, FAIL or NO VERDICT badge with a method label beside it. Only the label Re-tuned each window means each window was tuned on its first 70% and tested on the rest, on prices the tuning never saw.
- Robustness Scoring. Five stress tests ask whether the result depended on luck, for example whether a less lucky order of the same trades would have broken a drawdown limit. Read each test's own result before the 0–100 total.
- Prop Firm Evaluation. Each selected firm's rules are checked against the optimization trials, giving a Qualifies or Not Feasible badge and a Rule Results table.
Walk-forward analysis and robustness scoring can be skipped, so a finished run does not always show all five stages.
A high Match Rate shows that the re-run reproduced TradingView's trades, not that those trades were realistic. If the script used future data through a lookahead setting, a faithful re-run reproduces the same flaw.
Tradelyze does not place trades, hold funds, act as a broker or give financial advice, and it does not guarantee a challenge pass. Its results are hypothetical, and the prop firm rules it holds may be out of date. The prop firm check does not cover evaluation time limits, news trading or weekend holding. Tradelyze is not affiliated with TradingView or any prop firm.
Each results card is explained on the How Tradelyze validates a strategy page.
Where this appears in Tradelyze
In Tradelyze, the backtest you upload is re-run first and compared trade by trade on the Conversion Result card, the card that shows Match Rate.
To judge the whole report, not one tile, use the pre-trade checklist. If a stage fails or shows no verdict, see what each failing result means.
Tradelyze re-runs an uploaded TradingView Pine Script strategy from your exported trade list and price data, then runs parameter optimization, walk-forward analysis, a five-check robustness score and prop-firm rule checks. It does not place trades, give financial advice or guarantee a challenge pass, and it is in beta.
Already a user? Open your strategies.
Stage 1 · step 1 of 18. Next in the learning path: Exporting TradingView trades and price data
Frequently asked questions about backtesting
Questions about Tradelyze itself, such as which files to upload and how to read each results card, are collected on the Learn FAQ.
What is backtesting in trading?
Backtesting in trading is running a strategy's exact entry and exit rules over past price data to see which trades they would have taken and how the account would have changed. The result is a trade list, an equity curve and summary numbers such as win rate and maximum drawdown. A backtest describes the past only; it does not predict what the same rules will do next.
What is backtesting a trading strategy used for?
Backtesting a trading strategy is mainly used to reject bad ideas cheaply. Rules that lost money on years of past prices rarely deserve real money or a prop firm challenge fee. A profitable backtest earns further checks: trade count, expectancy, drawdown, how many settings were tried, a test on unseen data, Monte Carlo simulation and the firm's rules.
Is backtesting accurate?
Backtesting is accurate arithmetic on assumptions that are rarely exact. TradingView's Strategy Tester, for example, fills a signal from a bar's close at the next bar's open and guesses the price path inside each bar from its open, high, low and close. Missing costs, look-ahead bias and optimization bias all make results look better than live trading, so treat a backtest as an optimistic estimate.
Does backtesting work?
Backtesting works for what it can do: showing that a set of rules would have lost money, and measuring how a strategy behaved in the past. Backtesting does not work as proof of future profit. QuantStart's guide to backtesting calls a backtest an idealized upper bound on actual performance, because biases such as optimization bias and look-ahead bias are almost impossible to remove completely.
Is backtesting worth it?
Backtesting is worth it for most rule-based traders, because a failed backtest costs only time while a failed live strategy costs money or a challenge fee. The value depends on honesty: include commission and slippage, count the trades, record how many settings were tried, and test the final settings on data the optimizer never saw before trusting any number.
How far back should a backtest go?
No fixed number of years fits every strategy. A backtest should hold plenty of trades and more than one kind of market, such as trending, sideways, calm and volatile stretches. The more settings you try, the more history you need, as Bailey, Borwein, López de Prado and Zhu showed in a May 2014 paper. Tradelyze's minimum backtest length check wants at least one year, and more when many settings were tried.
What is survivorship bias in backtesting?
Survivorship bias is testing a strategy only on assets that still exist today, leaving out the ones that were delisted or failed. QuantStart's backtesting guide says survivorship bias can significantly inflate performance, with equities especially exposed and certain commodities and their futures less so. QuantStart's first remedy is price data that includes delisted stocks. A strategy tested on a single futures or forex chart is far less exposed, because it does not pick from a list of assets.
Why are my live results worse than my backtest?
Live results usually trail a backtest for two separate reasons. The first is overfitting: settings tuned until the past looked good partly fitted luck. The second is execution: live trading pays commission, spread and slippage, fills bar-close signals later, and can miss limit orders a backtest filled on touch. Overfitting needs fewer tuned settings and unseen-data tests; execution gaps need realistic costs.
How many trades does a backtest need?
No trade count guarantees a reliable backtest. Under about 30 trades, a general statistics convention rather than a trading-specific finding, figures such as win rate and profit factor describe too few events to support a conclusion. Higher counts such as 100 are widely quoted in trading education without a primary source. More trades across different market conditions make every other check more meaningful.
What is look-ahead bias in a backtest?
Look-ahead bias is using information in a backtest that would not have been available when the trade was made. QuantStart describes it as future data accidentally included in the simulation. TradingView's Pine Script documentation warns that request.security() with lookahead turned on and no one-bar offset returns data from the future on historical bars, which TradingView calls dangerously misleading.
What is an equity curve?
An equity curve is a chart of an account's balance after each trade or bar of a backtest. A smooth, rising curve means gains came steadily; a curve that reaches the same end point through deep dips carries more risk along the way. The largest fall from a peak on the curve, measured as a percentage of that peak, is the maximum drawdown.
Can a backtest tell me if I will pass a prop firm challenge?
A backtest cannot tell you whether you will pass a prop firm challenge, because the challenge happens on future prices. A backtest can show whether the strategy's worst past day or deepest drawdown would already have broken the firm's limits, which is a strong reason not to pay the fee. Tradelyze checks backtests against firm rules but does not guarantee a pass.
What does Tradelyze need to check a TradingView backtest?
Tradelyze needs the Pine Script strategy file, the trade list CSV exported from TradingView's Strategy Tester, and an OHLCV price data CSV for the same instrument and timeframe. Scripts that call request.security() or request.security_lower_tf() also need a CSV for each extra timeframe. The trade list is required because Tradelyze's first stage compares its own re-run with your TradingView trades.
Sources
- David H. Bailey, Jonathan M. Borwein, Marcos López de Prado and Qiji Jim Zhu, The Probability of Backtest Overfitting, revised working-paper version, February 2015, davidhbailey.com PDF. Defines a backtest as “a historical simulation of how an algorithmic strategy would have performed in the past”, and states that published backtests “almost never declare the number of trials involved in a discovery.”
- Campbell R. Harvey and Yan Liu, Backtesting, The Journal of Portfolio Management 42(1), Fall 2015, pages 13–28, DOI 10.3905/jpm.2015.42.1.013; quoted from the authors’ copy at Duke University, whose first page carries the running folio 12. Describes discounting reported backtest Sharpe ratios by 50% as common practice and calls the 50% haircut “only a rule of thumb.”
- David H. Bailey, Jonathan M. Borwein, Marcos López de Prado and Qiji Jim Zhu, Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance, Notices of the American Mathematical Society 61(5), May 2014. The minimum backtest length concept: the history needed to trust a backtest grows with the number of configurations tried.
- QuantStart, Successful Backtesting of Algorithmic Trading Strategies, Part I, quantstart.com, undated, retrieved 15 September 2026. Definition of backtesting; optimization bias, look-ahead bias and psychological tolerance bias; survivorship bias, which “can lead to significantly inflated performance for certain strategy types”, with equities especially exposed and datasets that include delisted entities as a remedy; a backtest as “an idealised upper bound on the actual performance of the strategy.”
- TradingView, Pine Script User Manual, Strategies, tradingview.com, retrieved 14 September 2026. Default fills at the open of the bar after a signal, the open, high, low, close path assumed inside a bar, limit order fills when price reaches or crosses the limit, and Bar Magnifier.
- TradingView, Pine Script User Manual, Repainting, tradingview.com, retrieved 14 September 2026.
request.security()with lookahead on and no offset returns data from the future on historical bars. - Tradelyze implementation, reviewed 15 September 2026: required files, the five run stages and their on-screen names, the Conversion Result card, the optimization objectives, walk-forward defaults, badges and method labels, the five robustness checks and the one-year floor of the minimum backtest length check and its growth with the number of settings tried, and the prop firm rules checked and not checked.
- The $10,000 worked example, its table and the equity curve figure are constructed illustrations, not measured data. The $20 cost per trade is an assumed figure; check your own broker's commission and typical slippage.