Both Chipotle (CMG 0.39%) and Costco (COST -0.07%) stocks have been huge winners for long-term shareholders. Their returns have more than doubled those of the S&P 500 index over the last 10 years, with Chipotle up 486% and Costco up 779%. The stocks have different but high-quality business models that have driven durable growth for many years, which should continue into the future.

But just because a business is good doesn't mean the stock is a buy. Investors looking at buying shares of Chipotle or Costco need to learn a history lesson from 50 years ago.

COST Total Return Level Chart

COST Total Return Level data by YCharts

The Nifty Fifty valuations

In the early 1970s, a lot of America's largest businesses saw their stock prices soar. These included well-known names like American Express and McDonald's. Investors started calling this group the Nifty Fifty -- 50 of the best stocks you could buy at any price. Or so the story went.

At its peak in 1972, the Nifty Fifty had a collective price-to-earnings ratio (P/E) of approximately 42. This was more than double the S&P 500 average. Subsequently, the United States faced a major inflationary period that drove all stock valuations down. The Nifty Fifty were hit particularly hard due to their high starting P/E ratios.

For example, McDonald's grew its revenue at a 24% rate from 1972 through 1980. Earnings per share (EPS) grew at a similar clip. Despite this, in 1980 McDonald's shareholders who bought in 1972 were sitting on a cumulative loss of 35%. Adjusted for inflation, these returns were a lot worse. Despite huge growth in the underlying business, McDonald's was a poor investment because of its high starting P/E ratio, another reminder that price matters when buying a stock.

This brings us to Chipotle and Costco.

Costco and Chipotle are more expensive than the Nifty Fifty

Chipotle and Costco have grown their sales at a consistent clip over the last 10 years. Chipotle's are up about 181% and Costco's are up 127% (cumulatively) over that time, which is similar but actually slower growth than McDonald's in the 1970s. With the stock prices soaring, a lot of investors seem to think this growth will be endless and that no price is too high to pay for Chipotle or Costco stock.

This will likely be foolish thinking. If you are buying Costco stock today, it trades at a P/E of 53. Chipotle is actually more expensive at a P/E of 65.5. Remember, the Nifty Fifty stocks traded at an average P/E of 42, which is significantly below what these two stocks trade at right now. A high P/E gives a stock more downside risk. Essentially, these two stocks are priced for perfection, which will likely lead to poor stock performance over the next 10 years.

Will Chipotle and Costco steadily grow their sales over the next decade? I think so. But these are not hypergrowth stocks that can grow into their earnings ratios within a few years. Costco's revenue only grew 5.7% year over year last quarter. This isn't Nvidia. At this pace, it will take the stock 10 years or longer to get back to an average market multiple. Same with Chipotle.

If valuations contract to a market average earnings multiple under 30, it is possible that both Costco and Chipotle post negative returns over the next 10 years. This is a major risk for investors buying today.

COST PE Ratio Chart

COST PE Ratio data by YCharts

The lesson investors need to learn

When a slower-growing business is at an extreme earnings ratio it is unwise to buy its common stock. I think this is what is happening today with stocks like Chipotle, Costco, and even some others such as Wingstop (this one actually has a P/E above 100).

This doesn't mean existing shareholders need to sell, though. If a business maintains its high quality, there is no reason to sell even if the P/E gets over-extended in the interim. Especially when you consider capital gains taxes. In fact, for the few shareholders that held the Nifty Fifty stocks through the 1970s and into the 1990s, the basket of companies actually ended up outperforming the S&P 500. However, I don't believe this means it was smart for anyone to buy McDonald's in 1972.

Costco, Chipotle, and other so-called unbeatable stocks feel eerily similar to the Nifty Fifty stocks of the early 1970s. Investors should take this as a history lesson and use it to avoid making mistakes with new buys in their portfolios today.