Glossary
Backtesting glossary
Short definitions of the terms that decide whether a backtest means anything – each with one example from our posts, from a real backtest or a worked example.
Pine Script backtesting
Reading backtest results
- Profit factor
- Profit factor is the gross profit of a strategy's closed trades divided by their gross loss. Above 1 the closed trades made money; below 1 they lost money.
Parameter optimization
- Parameter sweep
- A parameter sweep, or grid search, backtests every combination of a strategy's input values and returns one result per combination, so you see the whole result surface.
Trading costs
- Slippage
- Slippage is the difference between the price a strategy expected for an order and the price at which the order was actually filled.
Risk management
- Maximum drawdown
- Maximum drawdown is the largest fall of an account's value from a peak to a later low, usually stated as a percentage of the peak: (peak − trough) ÷ peak.
Overfitting and luck
Overfitting
- Overfitting
- Overfitting is tuning a trading strategy so closely to past data that it fits random noise instead of a repeatable pattern.
- Curve fitting
- Curve fitting is adjusting a strategy's rules or inputs until its backtest equity curve looks good on the data at hand. In trading, it is another name for overfitting.
- Selection bias
- Selection bias in backtesting, also called data snooping, is the optimism of picking the best of many tested variants: the more settings you try, the better the best one looks by chance alone.
- Hold-out test
- A hold-out test, or out-of-sample test, checks a strategy on data that was not used to build or tune it: you choose the settings on one part of the history and test them once on the part kept aside.
Walk-forward & Monte Carlo
- Walk-forward analysis
- Walk-forward analysis tunes a strategy on one window of history, tests it on the next window, then shifts both forward and repeats, so every tested piece uses only data from before it.
- Monte Carlo simulation
- A Monte Carlo simulation of a backtest rebuilds its result many times from resampled pieces of its own returns or trades, to show how deep the drawdown could have been in other paths of the same kind.
Data pitfalls
- Repainting
- Repainting is script behaviour that makes the calculations or plots of a Pine Script behave differently on historical bars than on real-time bars.
- Lookahead bias
- Lookahead bias means a backtest uses information that did not exist yet at the time of the simulated trade, such as the final high of a day that is not over.