Every investor dreams of buying low and selling high. And while that's a good goal, it can cause you problems if you take it too far.

If you try to time the market to buy at rock bottom or to sell at the peak and you get it wrong, you could cost yourself a fortune. According to research from Fidelity, the cost of poor market timing could be hundreds of thousands of dollars over your investing career. 

Broken piggy bank with coins spilling out.

Image source: Getty Images.

How much could trying to time the market cost you?

According to Fidelity's data, if you invested $10,000 in an S&P 500 index from Jan. 1, 1980, through Dec. 31, 2018, you'd have a whopping $659,515 by the end of that period, assuming you were invested for all of the days in that time frame. 

But if you missed just a few key days, your portfolio would be at least 35% smaller -- and potentially much smaller than that. In fact, here's how you'd fare based on the number of missed days:

If You Missed

Your Portfolio Would Be Worth

You'd Have Lost Potential Gains of

The 5 best days

$426,993

$232,522

The 10 best days

$318,036

$341,479

The 30 best days

$125,080

$534,435

The 50 best days

$57,382

$602,133

Table data: Fidelity.com.

As you can see, missing out on just five key days over 13,870 days of investing would leave you with a portfolio that's 35% smaller. And if you missed the 50 best days, you'd have 91% less than if you'd just left your money alone the whole time.

It may seem hard to believe you'd miss out on so many good days if you were trying to time the market. Unfortunately, if you're repeatedly reacting to its swings or trying to decide when to pull your money out and put it back in based on each day's economic news, there's a very good chance you will miss out on most or all of the key days that drive your profits. That's because people often tend to overreact to bad news, to assume things will get worse, and not to see a recovery coming until it's too late. 

What should you do instead?

Clearly, the cost of trying to time the market isn't worth it since being wrong by a few days could cost you hundreds of thousands of dollars. Instead, keep things simple. 

Buy index funds or high-quality stocks in companies you'd be happy to hold for decades. Purchase shares consistently over time regardless of what the market is doing. Then leave your investments alone unless you need to adjust your asset allocation or you lose confidence in the companies you own because the business environment shifts or the leadership team changes. 

If you do that over time, your investments should grow at a healthy rate, you'll build the nest egg you need, and you won't have to worry about missing out on hundreds of thousands of dollars in an effort to capture slightly more profits by timing the market.