As every investor knows, the stock market is cyclical, moving up and down for drawn-out periods of time. It would be great if you could invest and just watch your money grow in lockstep, but that's not how stocks work.

The bull market is now entering its tenth year, making it the longest market expansion since World War II, and the S&P 500 has more than quadrupled during that time. However, as the bull market has aged into the oldest in investors' memories, concerns about an impending bear market, defined as stocks falling at least 20%, have mounted. Jim Rogers, who co-founded the Quantum Fund with George Soros, said earlier this year, "When we have a bear market again, and we are going to have a bear market again, it will be the worst in our lifetime." 

Barry Bannister, head of institutional equity strategy at research firm Stifel, had a similar prediction, saying, "Our models for the S&P 500 point to minimal price upside in 2018 and a bear market (-20%) in the coming year." Of course, bear market predictions are nothing new, but as the bull market ages, fears have grown as stocks can't move higher forever.

While no one wants to invest on the eve of a bear market, looking at  history shows that a long-term investor can have the worst timing possible and still make money over the long run, simply by leaving their money in the market. Let's take a look at a few examples.  

A grizzly bear roars.

Image source: Getty Images.

Example #1: The eve of the great recession

On Oct. 11, 2007, the S&P 500 hit an all-time intraday high at 1,576.09. Stocks would crash over the next 17 months as the housing market buckled and then collapsed leading to a financial crisis that brought down Lehman Brothers and led to the government rescuing several major banks. Say you had invested $10,000 on Oct. 11. It surely would have been painful to watch your money disappear over the next year-and-a-half as the S&P 500 fell all the way to an intraday low of 666.79. By that point, 58% of your investment would have been erased.

However, as long as you held on through the crisis, you would be sitting on substantial gains of 67% today, for an annualized rate of about 5%. With dividends factored in, you'd have around 87% returns, or about 6% annualized. Of course, that's worse than the historical annualized growth of the S&P 500 around 9%, but your returns would still be better than inflation, Treasuries, or leaving your money in cash. On that $10,000 investment, you'd have gained about $8,700.

Example #2: The eve of the tech bubble bursting 

On March 24, 2000, the S&P 500 hit on all-time intraday high of 1,552.87. The market would soon unravel as dot-com start-ups folded and stocks proved to be overheated as traditional fundamental metrics like the P/E ratio, which had surged to more than 30, slowed. Over the next two-and-half years, the index would give up more than half of its value, falling to a low of 768.63 on Oct. 10, 2002. 

The market's peak in 2000 turns out to have been the worst time to invest in the last 45 years as you would have stayed in the red for most of the next 12 years. However, if you had held on, today you would have gains of 69% based on stock appreciation, or about 105% with dividends included. That works out to annualized gains of 3% without dividends or 4% with them. An investment in 10-year Treasuries would have beaten that at the the time but over the last five, 10-year Treasuries have yielded 3% or less. If you had invested $10,000 before the bubble burst in 2000, you'd still have decent gains with about $20,500 today.

Example #3: Black Monday

Going back further in time, the 1990s were a great period for investors as stocks surged with the exception of a mild recession in the early part of the decade. However, 1987 was famous on Wall Street for Black Monday on Oct. 19 when stocks crashed 20.5% on the S&P 500, the second-largest one-day percentage loss in market history. Prior to that, the S&P had peaked at 336.77 on Aug. 25, 1987, and the index bottomed out the day after Black Monday at an intraday low of 216.46. In total, you would have lost 36% in less than two months had you invested on Aug. 25 of that year.

However, as you can probably guess by now, you would have recovered nicely from that brief sell-off as the S&P 500 would move past the 336 level two years after your investment. Today, you'd have a gain of 580% over the 30-year span or an annualized gain of about 6%. With dividends, that annualized return is around 8%, or a total return of about 940%. On an investment of $10,000, that would turn into $104,000.

Add it all up

You could have been the worst market timer of the last 40 years, choosing the three worst days in that period to invest and you would still have sizable gains today as long as you left your money in the market.

The lesson for investors is clear. Though of course it's better to buy low than to buy high, it's much better to buy high than not at all. No one knows when the next bear market is coming, and hindsight is always 20/20. The examples above should reassure you that if you are a committed long-term investor, you will eventually win out with significant gains.

Though it may seem like a mistake to invest on the eve of a market crash, the biggest mistake of all you can make is sitting out the game entirely and not investing.