I couldn't for the life of me track down the actual quote, but Peter Lynch once said something along the lines of, "The biggest mistake an investor can make is buying the right company at the wrong price. Because then the company does well, but the stock goes nowhere."

How right he was! Most investors have lost money over the past few years. But what really caused these losses? Was it a deterioration of companies and their earnings power, or just a reevaluation by markets? There's a major difference between the two.

Consider these five companies, all of which have doubled (or nearly doubled) earnings in the past four to six years while their stocks went nowhere.

1. Microsoft (Nasdaq: MSFT)
In 2004, Microsoft earned $0.75 a share. Over the past year, it pulled down $2.10 per share. That's 18.7% earnings growth per year. Extraordinary. Yet Microsoft shares trade lower today than they did for all of 2004. Dividends provided some return, but shareholders have essentially been handed a donut for a company that's blown the lights out on earnings.  

2. Google (Nasdaq: GOOG)
Google shares have gone precisely nowhere since late 2006. The company, however, has been on a tear. Revenue has more than doubled since 2006. Ditto for earnings per share, which have jumped from $9.94 to $23.03. That's 23% annual earnings growth, for which investors were rewarded with bupkis.

3. Wal-Mart (NYSE: WMT)
Wal-Mart's business has famously done well during the recession as consumers flock toward frugalism. Earnings per share have nearly doubled since 2004, from $2.03 to $3.91. Yet during this same period, shares have flatlined.

4. Johnson & Johnson (NYSE: JNJ)
In 2005, J&J earned $2.74 per share. Over the past year, it nearly doubled that, to $4.84 per share. The company also almost doubled its dividend payout during this period. Its shares? They trade lower today than they did for most of 2005.

5. WellPoint (NYSE: WLP)
WellPoint is the strongest example of this group. In 2006, the company earned $4.82 per share. Over the past 12 months, it's made $11.23 per share. Yet during this four-year period, the company's shares have fallen 28%. Incredible.

I made a point here of staying within a four-to-six-year timeframe. Stretching this exercise out to 10 years brings you back to dot-com bubble territory, where examples of companies growing earnings while their stocks pooped out becomes the norm.

Why does this happen? There are three explanations for why a company's earnings can explode while its stock languishes:

  1. The current valuation is too low.
  2. The starting valuation was too high.
  3. Future growth prospects have suddenly taken a nosedive.

The recent period of dismal returns probably owes somewhat to all three factors. But the first two -- the valuation issues -- deserve the lion's share of your attention.  

At a conference I recently attended, value investor Vitaliy Katsenelson made a great point: History shows that the single most important statistic in determining market returns is not GDP growth, interest rates, or even earnings growth. It's starting valuations. Start with high valuations, and future returns will be poor, even if companies and the economy boom. Start with low valuations, and future returns can be great, even if companies simply trod along. That's the point Lynch was making as well.

So where are we now? It's not hard to make the case that current valuations for these companies -- and most large caps, for that matter -- are indeed low. Microsoft, for example, trades at about eight times earnings after backing out its cash hoard. Johnson & Johnson's dividend yield is 3.5% -- far higher than 10-year Treasuries -- and it's grown that dividend payout by more than 12% per year for the past 30 years. Wal-Mart trades at 12 times forward earnings, despite having the most powerful retail moat known to mankind. There's no way to describe these numbers as anything other than outrageous. They're simple reflections of investors extrapolating previous poor results into the indefinite future.

There are two important parts to successful investing: finding the right company, and finding the right price. In any market, singling out good companies isn't terribly difficult. They're usually well-hyped. But finding the right price can be painfully elusive. Thankfully, the pool of good companies selling at good prices today is about as deep as it's been at any time during the past decade.

For past 10 years, strong companies provided abysmal stock performances. Over the next ten, I have a feeling  that mediocre companies will start providing strong stock returns. These things move in cycles.           

Check back every Tuesday and Friday for Morgan Housel's columns on finance and economics.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.