You’ve heard it before: timing is everything.

The idea is certainly appealing: Buy an investment at or near the bottom, sell it at or near the top, and repeat. With markets near all-time highs and a wave of fresh volatility washing over their psyches, investors today may be even more attracted to a market timing approach.

The problem, of course, is only with the benefit of hindsight are such market peaks and troughs clearly visible.

What does hindsight tell us?

The Right Time to Invest

To answer that question, we used S&P 500 monthly return data from January 1988 through December 2017 to identify the best and worst times to invest each year. We then compared two different paths a “lucky” and “unlucky” investor took.

Consider the Lucky Investor. She starts with $100,000 thirty years ago and adds $10,000 per year. Each calendar year, she adds to her portfolio at just the right time—when stock prices are at their lowest—and never sells.

From 1988 through 2017, this Lucky Investor amassed a nest egg worth nearly $3.8 million. From her initial $100,000, that represents a compound annual return of nearly 12.9%.

Not So Unlucky After All

By contrast, the Unlucky Investor starts with the same $100,000 and invests $10,000 at the market peak each year for 30 years. At the end of 30 years, he’s earned 12.7% per year for an ending wealth of nearly $3.7 million. That’s just 3% less than the ending wealth of his “lucky” counterpart—a marginal difference over thirty years.

For those no longer adding to their portfolios but rather living off their nest eggs, the story is much the same: Whether making annual withdrawals when prices are at their highest or at their lowest, ending wealth is similar over a typical retirement horizon.

Time Is Everything

Will markets stumble in the future? That’s not a matter of if, but when. Will we know the exact cause or timing? Of course not. But the investor who gets and remains invested—regardless of “lucky” or “unlucky” timing—has the best chance of a successful investment experience.

The bottom line is, it is time in the market, not timing the market that matters most.