What Is Backtesting?

Let’s start with defining what backtesting actually is:

Backtesting is the process of testing a trading idea or strategy on historical quotes/data. You form a hypothesis, you collect the data to test on, and then you make rules and then backtest. It’s actually quite simple (in theory, at least).

A backtested strategy that demonstrates good realistic profitability and stability, gives confidence in its performance or at least deserves further attention and research.

However, backtesting is no bulletproof science, something we explain in the next lesson. But backtesting most likely allows you to reduce the possibility of losing money in live trading if done correctly.

Here is an example of a backtest:

You have probably heard the expression “sell in May and go away”.

Is it any truth in this? The only way to know for sure is to look at monthly returns in S&P 500 over many years. It’s a really simple backtest.

For example, you buy the close of April and own S&P 500 for 1, 2, 3, 4, or 5 months (or more).

If you do this backtest you’ll find out that the S&P 500 hardly had any positive returns from May until the end of September.

Below is the equity curve (equity curve is further explained later in the course) of being invested in the S&P 500 from the start of May until the end of September every year from 1960 until today:

You would have lost money if being invested only during those few months!

Opposite, if you bought in early October and owned the S&P 500 until the end of April you would have made good money:

This is what backtesting is all about: to get answers about the historical returns of a hypothesis. In our opinion, we can safely say that “sell in May and go away” is somewhat true.

A backtest follows this procedure:

  1. Find an idea you want to test.
  2. Define clear and concise entry and exit parameters – they need to be quantifiable.
  3. Specify the market you want to test on.
  4. Specify the time frame you want to test.
  5. Code the strategy.
  6. Run the strategy on the in-sample period (more later).
  7. Test the out-of-sample backtest (more later).

To better explain those points we need to go further into the course. Let’s jump to our next lesson: