Many investors worry that high-profile, high-flying stocks such as Amazon and Netflix have reached unsustainable price levels, propelled by a tech mania. But there are other very popular stocks whose blue-chip reputations have hidden the dangers that make them risky—perhaps even riskier than the tech juggernauts.

Don’t be fooled by these “safe” companies’ strong balance sheets and steady dividends. Investors have run up the share prices of these blue chips, especially in the past three years, spurred on by a strong economy, booming corporate profits and the huge corporate tax cuts that took effect this year. These stocks have grown so pricey, in fact, that they seem to offer little upside in the next few years. And the companies face significant challenges that could slow their earnings growth. If we hit a recession and/or a bear market, their stock prices could plunge faster and further than the overall market.

Here’s how to know when a blue chip becomes very overvalued and which surprising ones you should be wary of now.

How To Tell

Just because a company has a great reputation as a business doesn’t mean that its stock is worth owning at any given time. To get a quick snapshot of a stock’s relative value, look at two key measurements (both of which you can find for any stock at Morningstar.com or at another financial-market website or through the company’s investor relations office). The trailing price-to-earnings ratio (P/E) tells you how expensive the stock shares are relative to the company’s earnings over the past 12 months. You can compare a stock’s P/E to those of the company’s competitors and to that of a broad market index such as the Standard & Poor’s 500.

Also check the price-to-sales ratio (P/S), which compares a company’s stock price to its sales figures over the past year. It’s much harder for a company to manipulate its sales figures than its earnings. If a company’s recent P/S is higher than its average P/S over the past decade, it could be a good indicator of overvaluation, and you need to explore other factors, such as the challenges the company has in the near future, to decide whether its shares are worth owning.

What to do about overvalued stocks whose near-term future does not look attractive: If you are investing new money, you should avoid these stocks and look for better bargains. If you already own them in a tax-deferred or tax-free account, sell them and look elsewhere. If you already own them in a taxable account and have significant capital gains, it’s a tougher call. One rule of thumb is to hold on to them only if you have a time horizon of at least 10 years before you’ll need the cash from selling them. Otherwise, sell them and invest in better-valued stocks.

The following five popular blue-chip stocks all had recent P/Es higher than that of the S&P 500 (recently about 23, which is well above its own historical average of 15)…and their recent P/Ss were all much higher than their long-term averages, with some at record highs.

3M (MMM)

Even after a pullback this year, the stock of this 116-year-old industrial giant is very expensive. Last year, the share price soared 34% as the company, which sells 55,000 different products including Post-it notes and Scotch tape, benefited from the struggles of one of its chief competitors, GE, and from stronger US profit growth. But investors are missing the fact that 3M operates in 70 countries and derives about two-thirds of its revenue from overseas. The slowdown in emerging-market economies and the dollar’s rise against foreign currencies will be an increasing drag on the company’s overall profit growth. Recent valuation measurements: P/E 30.3…P/S 3.7.*

Johnson & Johnson (JNJ)

Stock in the world’s largest health-care company shot up 24% last year. That’s not because of profits from its iconic consumer brands such as Band-Aid, Tylenol and Johnson’s Baby Shampoo—all of which barely grew—but rather because of Johnson & Johnson’s lesser known pharmaceutical division, which accounts for about 70% of overall profits. Investors were particularly excited about several acquisitions including ­Actelion, which makes a very profitable pulmonary hypertension drug. Going forward, however, it will be difficult for J&J to make up profits from the loss of patent protection on its blockbuster drugs such as Remicade for autoimmune diseases such as rheumatoid arthritis. I also worry about the company’s legal problems. In July, a circuit court ordered it to pay $4.7 billion to families who had claimed that asbestos in the company’s talcum-powder products caused ovarian cancer. The company plans to appeal that order, but a broader ­ongoing battle over talcum safety is far from over. Recent valuation measurements: P/E 253.5…P/S 4.5.

McDonald’s (MCD)

McDonald’s is a no-value meal right now. The company remains a powerhouse in the global restaurant industry, with strong international profit growth last year. And investors have cheered the company’s efforts to boost sluggish domestic performance through its rollout of all-day breakfast items, self-ordering kiosks and home delivery. But the US fast-food industry is up against a massive shift in consumer tastes that favors higher-end, higher-quality fast-casual restaurants. McDonald’s will continue to lose market share in the US (where it derives about 35% of its profits) to competition such as Panera Bread, Shake Shack and Chick-fil-A. Recent valuation measurements: P/E 27…P/S 6.1.

Microsoft (MSFT)

Because it gets much less buzz in the media and on Wall Street, Microsoft is often regarded by investors as a more mature but cheaper alternative to the FAANG stocks (Facebook, Amazon, Apple, Netflix and Google parent Alphabet Inc.). The stock has gained more than twice as much as the S&P 500 over the past three years as the software company continues to transform itself from a lazy, ­monopolistic giant into a global player in cloud-computing services. But recently, Microsoft sported a higher valuation than Alphabet and Facebook. The concern: Although its cloud business is booming, its other business lines are mature and unlikely to keep up with the growth of rival tech giants. Microsoft remains the second-place cloud vendor behind Amazon. Its Bing search function will never catch up to Google. The Xbox game system trails Sony’s PlayStation. And Windows OS missed the mobile-phone boom that led to the near-monopoly of Apple’s iOS and Google’s Android. Recent valuation measurements: P/E 57…P/S 7.6.

Nike (NKE)

Just don’t do it. Stock in Nike, the world’s largest designer and wholesaler of athletic footwear and apparel, shot up 36% this year, in part thanks to the company’s casting of ex-NFL quarterback Colin Kaepernick at the center of its latest “Just Do It” ads. This edgy choice struck a chord with investors who are hoping it will boost US sales. But given its recent price, Nike faces too many challenges to justify sticking with the stock in the near-term. The company is losing market share in the US to smaller rivals such as ­Adidas and Under Armour, and its retro styles and basketball shoes don’t resonate with consumers who increasingly want more stylish “athleisure” wear. Recent valuation measurements: P/E 59.1…P/S 3.3.