Recession fears sent the S&P 500 tumbling into a bear market last year, and the benchmark index is still down 12% from its high. But history says that drawdown is temporary. Every past bear market has eventually ended in a new bull market, and investors have no reason to expect a different outcome this time. That makes the current situation a buying opportunity, but not every fallen stock is worth buying.

Consider this investing advice from Warren Buffett.

Buy and hold high-quality stocks

Buffett once said, "All there is to investing is picking good stocks at good times and sticking with them as long as they remain good companies." There are two important lessons there. First, valuation matters. A great business at the wrong price can be a terrible investment. Second, think long-term. Investors should ignore the day-to-day fluctuations in the market and instead focus on buying and holding good stocks.

But what qualifies as a good stock?

Invest in companies with a competitive advantage

In his 1995 letter to Berkshire Hathaway shareholders, Buffett wrote the following: "In business, I look for economic castles protected by unbreachable moats." The term "moat" refers to a competitive advantage, the quality or qualities that protect a business from its competitors.

There are many different types of competitive advantages. Apple possesses immense brand authority that not only keeps consumers loyal, but also affords the company a great deal of pricing power. Amazon Web Services offers a broader and deeper suite of cloud computing products than any other cloud provider. Nvidia can design more performant graphics chips and data center accelerators than other semiconductor companies. Costco Wholesale derives significant purchasing power from its scale, and its operating expertise further enhances that purchasing power.

All of those stocks have crushed the S&P 500's return over the past decade, and investors can attribute those market-beating performances to the fact that each company possesses a durable competitive advantage.

Buy stocks within your circle of competence

In his 1996 letter to Berkshire shareholders, Buffett wrote the following:

You don't have to be an expert on every company, or even many. You only have to be able to evaluate companies within your circle of competence. The size of that circle is not very important; knowing its boundaries, however, is vital.

Buffett expanded on that advice a few years later. In his 1999 letter to Berkshire shareholders, Buffett explained that he typically avoids investing in technology companies -- despite knowing their products and services will transform the world -- because he finds it difficult to identify competitive advantages in that sector. In other words, Buffett avoids technology stocks because they are beyond his circle of competence.

Think carefully before buying or selling a stock

Buffett once said, "An investor should act as though he [or she] had a lifetime decision card with just twenty punches on it." Those words should not be taken literally -- Berkshire owns far more than 20 stocks. Instead, Buffett is telling investors to think deeply about every decision. Never buy or sell a stock on a whim.

Knowledge can pay huge dividends

Buffett once said buying Benjamin Graham's book, The Intelligent Investor, was the best investment he ever made (excluding two marriage licenses). Graham is viewed as the father of value investing, and his teachings formed the bedrock of Buffett's investing style. The message here is simple: Never stop learning. An investment in knowledge can produce incredible returns.