The past several years have been a whirlwind for investors. After soaring to new heights in 2021, the major market indexes did an abrupt about-face, plunging into the worst bull market in more than a decade. But after spending more than a year in the dumps, stocks have come roaring back, with the S&P 500 and the Nasdaq Composite up 14% and 29%, respectively (as of this writing), so far in 2023.

Yet opinions are divided about what will happen next. As recently as March, the Federal Reserve Bank warned of a possibility of a mild recession at some point this year. At the same time, the S&P and the Nasdaq are both up by more than 20% from their recent lows, which by some standards means a new bull market has begun. With all these seemingly contradictory indicators, what are investors to do?

People could do worse than follow the advice of renowned Berkshire Hathaway CEO Warren Buffett, who has an unsurpassed track record of investing success dating back decades. In short, the Oracle of Omaha argues now is the time to invest.

Warren Buffett smiling.

Image source: The Motley Fool.

Uncertainty abounds

Buffett acknowledges the uncertainty that accompanies periods that feature ongoing economic challenges, laying out the situation in stark terms: 

The financial world is a mess ... its problems, moreover, have been leaking into the general economy, and the leaks are now turning into a gusher. In the near term, unemployment will rise, business activity will falter, and headlines will continue to be scary.

While this could be viewed as an apt description of the current situation, you might be surprised to find that this commentary was expressed at the height of the Great Recession in October 2008, in an opinion piece Buffett penned in The New York Times. Yet in it, he was also unequivocal that he was at that time buying stocks. Notably, the piece was published just months before the ensuing rebound. 

At the time, Buffett couldn't have possibly known that the market was already near its bottom and was about to embark on the longest bull run in stock market history.

^SPX Chart

Data by YCharts.

Buffett went on to say that no one could know for sure what would happen in the near term, but asserted that investors who kept their eyes firmly on the future would be richly rewarded (emphasis mine):

I can't predict the short-term movements of the stock market. I haven't the faintest idea as to whether stocks will be higher or lower a month or a year from now. What is likely, however, is that the market will move higher, perhaps substantially so, well before either sentiment or the economy turns up. So, if you wait for the robins, spring will be over.

He also said that "most major companies will be setting new profit records five, 10 and 20 years from now ... over the long term, the stock market news will be good."

In other words, it doesn't matter if there's a recession or bull market in 2023. Investors should simply buy and hold for years, if not decades.

Buying stocks on sale

According to Buffett, one of the biggest mistakes investors make is paying too much for stocks. "Price is what you pay; value is what you get," he has said often, quoting his mentor Benjamin Graham -- the father of value investing. One of the best ways to avoid paying too much is to buy stocks when they're cheap. "Whether we're talking about socks or stocks, I like buying quality merchandise when it is marked down," said Buffett. 

One such company is Taiwan Semiconductor Manufacturing Company (TSM -1.08%) (also known as TSMC). It's the world's leading third-party chipmaker and is well positioned to benefit from the ongoing boom for chips used in artificial intelligence (AI).

Many investors piled into Nvidia (NVDA -0.59%) after that company reported better-than-expected results for its fiscal 2024 first quarter (which ended April 30), and rightly so. Nvidia is the leading provider of processors used by AI systems. Helping fuel the excitement was a robust forecast, which guided for 64% year-over-year revenue growth in the current quarter, the result of soaring demand for AI. However, this helped drive Nvidia's valuation into the stratosphere -- the stock is currently selling for 224 times trailing earnings and 42 times sales. 

On the other hand, TSMC -- which manufactures all of Nvidia's advanced processors -- is trading for just 16 times earnings. To give that context, the S&P 500 currently has a price-to-earnings ratio of 25, making TSMC a screaming bargain.

It's worth noting that Berkshire recently sold its position in TSMC due to Buffett's concerns about geopolitical tensions in the region. "I wish it weren't sold," he said, "but I think that's a reality." He went on to call TSMC "one of the best-managed companies and [most] important companies in the world ... There's no one in the chip industry that's in their league, at least in my view," Buffett said. That's high praise coming from one of the most successful investors of all time, who analyzes business performance for a living.

Buying a business with a moat

Another yardstick used by Buffett when considering stocks is assessing a company's economic moat -- in other words, the durable competitive advantages that will allow it to flourish even in the midst of robust competition.

One of the best examples of a Buffett stock with a seemingly unassailable moat is Apple (AAPL 3.41%). Buffett cites the iPhone's loyal customers as providing that moat. In fact, he believes iPhone users wouldn't give up their devices even if there was a significant financial incentive to do so.

"If you're an Apple user and somebody offers you $10,000 but the only proviso is that they'll take away your iPhone and you'll never be able to buy another, you're not gonna take it," Buffett said in a recent Barron's interview. 

Buffett is also a big fan of Apple's dividend, which the company recently increased by 4% to $0.24 per share each quarter. In fact, since the company resumed those payouts in 2012, it has increased its dividends by a whopping 153%.  

He has also opined about Apple's stock buybacks, saying he's "wildly in favor" of them. He notes that this practice increases Berkshire's ownership of each and every dollar of Apple's profits, without any additional investment on his part. 

The time is now

To tie this all in a bow, Buffett admits that the future is uncertain and that he has no clue as to what will happen over the short term. That said, he likes buying solid businesses at a discount, while focusing on those with an economic moat. Once that's done, he usually lets time do the rest by holding those stocks for the long term. This provides a solid framework for investors who want to emulate Buffett's style -- and his results.