Backtesting guide
Backtesting Investment Strategies
Backtesting an investment strategy applies explicit selection, allocation, and rebalancing rules to historical information. The output is a hypothetical portfolio path under the stated assumptions, not proof that the investment would have been profitable in practice.
Read the practical guideKey Takeaways
- Specify selection, allocation, cash-flow, and rebalancing rules before testing.
- Use consistent income, currency, cost, and benchmark definitions.
- Separate contributions from investment performance.
- Judge the original hypothesis with saved baselines and validation data, not a universal metric cutoff.
Specify the investment policy before looking at returns
Define the eligible assets, target weights, rebalance schedule or drift bands, contribution and withdrawal dates, and treatment of cash. State when information becomes available and when a trade can occur. A rule that ranks assets at month-end and trades at that same closing price needs a defensible timing assumption. Distinguish a fixed portfolio of named funds from a selection rule applied to a changing universe. The latter needs point-in-time membership and relevant delisted assets. A fund price history cannot be extended before its launch without clearly labeling the substitute series and the assumptions it adds.
Reconcile holdings, income, and costs
Value every holding and the cash account on a common schedule. Process splits, distributions, fees, and trades consistently. Dividend-adjusted returns and separately credited dividends must not both count the same income. Specify currency conversion and whether taxes, borrowing, or funding are included. Model rebalance turnover and trading costs rather than applying an arbitrary commission to every portfolio. Cost assumptions should match the broker, instrument, order size, and available evidence. Save a baseline and compare higher-cost scenarios; a favorable result under one cost setting is not a capacity estimate.
- Save the dataset version, asset identifiers, dates, and adjustment definitions.
- Record weights before and after rebalancing and the trades required to restore targets.
- Check that total portfolio value equals marked holdings plus cash after each event.
Separate investment return from money added to the account
An account can grow because of contributions even when its investments lose value. Time-weighted return separates performance into periods around external cash flows and links their returns. Money-weighted return incorporates the size and timing of contributions and withdrawals. They answer different questions, so label the method instead of comparing unlike percentages. For an arithmetic illustration, an account that starts at $10,000 and receives a $2,000 contribution at the end of a flat period ends at $12,000. That is not a 20% investment gain. For a contribution during the period, the timing and interim valuations matter. The GIPS handbook explains these measurement distinctions; using them here does not claim GIPS compliance for a hypothetical test.
Compare against a benchmark on the same basis
Choose a benchmark that reflects the investment opportunity and risk being evaluated. Align dates, currency, income treatment, and return calculation. Explain differences in fees or tradability rather than treating a gross index return as a directly obtainable net result. Inspect total return, periodic returns, drawdown depth and duration, turnover, and concentration. For a buy-and-hold portfolio, trade win rate or profit factor may add little information because few positions close. A 50% loss requires a subsequent 100% gain to recover without cash flows, but historical maximum drawdown is not a bound on future losses. No Sharpe or profit-factor cutoff certifies suitability.
Test the hypothesis without redefining it after every result
Reserve validation dates before selecting parameters and keep a record of alternatives tried. Check sensitivity to rebalancing timing, cost assumptions, data adjustments, and starting dates. If repeated inspection changes the rules, that period has become development data. A strategy designed for one market need not work identically on every other instrument. Test the scope of the original claim. Evidence across other markets can be useful, but selecting only the successful ones creates another selection problem. There is no universal minimum of 100 trades or five years for every investment policy.
Use the right engine for the portfolio
A TradingView strategy can test chart-based trading rules, while requests for other symbols can supply signals. Those requests do not automatically create a shared-cash, multi-asset portfolio simulation. Use an engine that explicitly tracks the holdings, cash flows, and simultaneous orders required by the investment policy. Pineify can help draft a Pine Script component for testing in TradingView. Its Backtest Report analyzes compatible trade exports; it is not a full portfolio accounting or contribution-return engine. Do not label its trade-based ratios as portfolio time-series statistics without checking the calculation.
Primary sources
- SEC Investor Bulletin: Performance claimsVerified 2026-10-20
- GIPS Standards Handbook: Return measurement and cash flowsVerified 2026-10-20
- QuantConnect: Corporate actionsVerified 2026-10-20
- TradingView: StrategiesVerified 2026-10-20
This is an educational testing framework, not an investment recommendation. Hypothetical and historical performance do not guarantee future results.