How to backtest a trading strategy
A step-by-step method to backtest a trading strategy: data, costs, trade count, out-of-sample tests and the checks that separate an edge from a lucky fit.
Guides to the methods that separate a trading edge from a backtest that fits the past.
Start with a backtest, then follow the checks that match your data, validation method and export target.
Define the rules, the data and the split before reading a performance number.
A step-by-step method to backtest a trading strategy: data, costs, trade count, out-of-sample tests and the checks that separate an edge from a lucky fit.
The difference between in-sample and out-of-sample testing in trading, how to split the data, and the mistakes that leak test data into the design.
How walk-forward analysis and walk-forward optimization test a trading strategy on successive unseen windows, with rolling and anchored schemes compared.
What overfitting and curve fitting mean for a trading strategy, how to tell an overfit backtest from a robust one, and the tests that measure it.
Check when an observation became available, when a signal was formed and when an order could fill.
What look-ahead bias is, how it enters a backtest through data, indicators and Pine Script request.security, and how to detect it before you trade.
How data revisions leak into backtests, how ALFRED vintages recover values as published on a past date, and a revised-signal example worked by hand.
Separate the time a signal is computed from the time its order can fill, with a one-bar shift worked through on daily prices and the latency it omits.
How a current survivor list distorts historical backtests, a hand-calculated universe example, and checks for delistings and point-in-time membership.
Model commissions, spread and slippage on each fill, calculate net return from a round trip, and test how execution assumptions change results.
Separate a repeatable result from a lucky choice among configurations or samples.
Compare a parameter plateau with an isolated peak, compute a neighborhood average by hand, and relate sensitivity checks to PBO and CSCV.
How overlapping labels leak across cross-validation folds, how purging and embargo remove them, and how CPCV forms multiple test paths.
What the probability of backtest overfitting (PBO) measures, how combinatorially symmetric cross-validation computes it, and how to read a PBO score.
Compare White's Reality Check, Hansen's SPA, Romano-Wolf StepM and the deflated Sharpe ratio with a hand-calculated false-positive example.
Test whether a strategy survives changes in return distribution and parameter fit, with a calculated segment example and structural-break diagnostics.
Select a statistic that fits the question and examine its sampling uncertainty.
Compare Sharpe and Sortino ratios, calculate each from a small return series, and see why the downside target and observation frequency matter.
What the deflated Sharpe ratio corrects for, its formula from Bailey and López de Prado, and why a high Sharpe ratio after many trials can still be luck.
Derive minimum track record length from a Sharpe estimate, skewness, kurtosis and confidence level, with the published monthly example reproduced.
How Monte Carlo simulation stress-tests a trading strategy, what trade shuffling misses, and why block bootstrap keeps the losing streaks that matter.
Define a trading-signal permutation null, compute a finite-sample p-value from shuffled outcomes, and distinguish inference from path simulation.
How to estimate the probability of passing a prop firm challenge from a strategy's own trades, with daily loss limits, maximum drawdown and profit target.
Inspect the simulator and the translation limits of a strategy intended for another platform.
How TradingView simulates Pine strategy trades, where historical fills and repainting affect results, and how to test selection before export.
How MetaTrader 5 test modes, genetic optimization and forward periods affect Expert Advisor results, with checks before an MQL5 export.
The actual path from a Stochastly strategy graph or supported custom Python signal to MQL5, including translation refusals and parity checks.
Documentation explains how the app runs these checks. Research library traces the methods and source material. Interactive tools let you inspect selected calculations.