The U.S. stock market has been going up, almost uninterrupted, for the better part of nine years. The S&P 500 index is historically expensive, trading for around 26 times trailing-12-month earnings. The long-term average is closer to 15. Tech stocks are even pricier, with giants like Microsoft and hot stocks like NVIDIA trading for dozens of times earnings.

There are a few good reasons for stocks to be so expensive. Interest rates have been low for a long time, making even expensive-looking stocks attractive relative to the alternatives. Warren Buffet said last year that "valuations make sense with interest rates where they are." The tax bill passed in December is another factor. Companies that derive much of their profits from the U.S. will see a substantial boost in earnings.

But bull markets don't last forever. There's no telling for how long the current one will continue. It could be six months. It could be six years. But it will end sooner or later. Buying wildly expensive tech stocks has worked like a charm in the past few years. They just seem to keep going up. But if the market crashes, or even goes through a gentler reckoning, those popular stocks could become unpopular fast.

A man holding his head as he looks at a slumping stock chart.

Image source: Getty Images.

A good strategy, then, is buy tech stocks that are unpopular now and have missed out on the historic bull market we find ourselves in and that trade for pessimistic valuations. There's no better example than International Business Machines (IBM -0.89%).

A rare value in tech

Long story short, IBM has had a rough few years. Revenue has been in decline for half a decade, as the company has transitioned away from slumping legacy businesses into areas including cloud computing, artificial intelligence, and security. The stock has followed suit, down 15% over the past 5 years, a period when the S&P 500 surged 87%.

IBM Chart

IBM data by YCharts.

There's quite a bit of pessimism baked into IBM's stock price. Based on the company's adjusted earnings guidance for 2017, the stock trades at a price-to-earnings ratio below 12. That's not even in the ballpark of many of its peers:

Stock

P/E ratio

IBM

11.8

Intel

13.2

Apple

15.2

Cisco Systems

16.2

Oracle

16.7

Microsoft

25.9

Facebook

31.9

Alphabet

33.9

NVIDIA

52

Salesforce

81.1

Amazon

287.7

P/E ratio based on average analyst estimate for 2017 adjusted earnings, or the current fiscal year if 2017 results have already been reported. Data source: Yahoo Finance.

This type of valuation would make sense if there was little hope of IBM ever returning to growth. But the company is on the cusp of doing just that. Thanks to the launch of its latest mainframe, as well as the continued double-digit expansion of its growth businesses, IBM expects to end its steak of revenue declines in the fourth quarter of 2017. Multiple tailwinds, including a weaker dollar, should help carry this momentum into 2018.

A full 45% of IBM's revenue over the past year has come from its growth businesses, which are growing at a double-digit rate. Cloud computing accounted for 20% of total revenue, and it grew by 20% in the third quarter. IBM's blockchain business seems to be gaining steam, with a slew of partnerships announced over the past year. And long-term initiatives like quantum computing will give IBM a shot at leading the next revolution in computing.

In a historically expensive market that's been going in one direction for nearly a decade, IBM stock looks like an awfully good idea.