Tradelyze

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:

The outputs of a backtest are:

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:

expectancy per trade = (win rate × average win) − (loss rate × average loss)
= (0.45 × $300) − (0.55 × $200) = $135 − $110 = $25
Constructed example: one backtest's results before and after trading costs
MeasureNo costs$20 cost per tradeHow it is worked out
Trades404018 winners plus 22 losers
Win rate45%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$5Net profit ÷ 40 trades
Return on $10,00010%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.

Equity curve of a constructed 40-trade backtest with its maximum drawdown marked Constructed illustration, not measured data. A line chart of account balance against the number of trades taken, from 0 to 40 trades. The balance starts at 10,000 dollars, is 10,300 after 5 trades, 10,150 after 10, 10,600 after 15, and reaches a peak of 11,200 after 20 trades. It then falls to 10,800 after 25 trades and to a low of 10,360 after 28 trades, recovers to 10,700 after 33 trades, and ends at 11,000 after 40 trades. A dashed line at the 11,200 peak and a red vertical line down to the 10,360 low mark the maximum drawdown: a fall of 840 dollars, which is 7.5 percent of the peak. Account balance after each trade (constructed example) $10,000 $10,500 $11,000 0 20 40 Trades taken Peak $11,200 Low $10,360 Drawdown: $840 = 7.5% End $11,000
Constructed illustration, not measured data. The test ends 10% up, but on the way the account fell $840 from its $11,200 peak, a 7.5% maximum drawdown. Two strategies with the same final profit can have very different drawdowns, which is why the equity curve matters as much as the end result.

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.

Why backtests look better than live results, and what to check for each cause
CauseWhat goes wrongWhat to checkSource
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:

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.

  1. 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?
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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 five stages, in the order a run shows them:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

Create an account

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