Tools

Backtest playground

Pick trading rules and apply them to real daily prices. Choose from the S&P 500 index going back to 1927, the Nasdaq, the semiconductor index, the KOSPI and KOSDAQ, and 34 US and Korean ETFs including SPY, QQQ, TQQQ, SOXL, SCHD, TLT and KODEX Leverage.

Start from a style button, then change the rules and numbers. You can add a stop-loss, a take-profit, a maximum holding period and short selling. Your setup is stored in the page address, so "Copy link to this setup" lets anyone open exactly what you are looking at.

What this calculation assumes

  • Signals use information up to each day's close, and trades happen at the next day's open.
  • Stop-losses and take-profits fill at their price when the day's range reaches it, or at the open if the day opens beyond it. If both are reached on the same day, the stop-loss is assumed.
  • After a stop-loss, take-profit or time-limit exit, the strategy waits for its signal to switch off and on again before re-entering.
  • Trading cost is charged in proportion to the amount on every buy and every sell. Flipping from long to short pays it twice.
  • Interest on cash, dividends, taxes and the borrowing fee for short sales are left out. Including dividends would make buy and hold look better than it does here.
  • ETFs use prices adjusted for reinvested dividends. Indices use prices without dividends, so buy and hold on the S&P 500 index shows less than an investor could actually have earned.
  • Without minute-by-minute data, day trading and scalping cannot be tested here. They are planned as separate games.

About the data

  • Prices are daily open, high, low and close from Yahoo Finance (via yfinance). They are offered for personal analysis, with no guarantee of accuracy.
  • Older index data covers some years with closing prices only (before 1962 for the S&P 500). There the open, high and low are taken to equal the close, so stop-losses and take-profits work on closes only.

A caution before you read too much into it

Move the window N around and some value will look unusually good. The "find it in one decade, test it in the next" section at the end of the playground above shows the trap directly. It will feel like the "right answer", but trying many values and keeping the best is exactly what turns luck into apparent skill. It is the same thing as the fake-strategy experiment in the efficient market hypothesis article.

A result from one index over one 20-year stretch is an experiment with a sample of one. Past performance does not guarantee future results.