The S&P 500 (^GSPC 1.02%) soared 24% in 2023, and investors have bid the benchmark index to multiple record highs this year. Factors contributing to that upward momentum include fading inflation, the resilient economy, a rebound in corporate earnings, and expectations that the Federal Reserve will cut interest rates in the near future. Fascination with artificial intelligence has also sent many stocks higher in recent months.

However, the S&P 500 now trades at 20.4 times forward earnings estimates, a meaningful premium to the 10-year average of 17.7. As a result, certain Wall Street analysts see a drawdown on the horizon. For instance, JPMorgan Chase has set a target of 4,200 for the S&P 500, implying about 15% downside from its current level.

Investors wondering whether it's safe to buy stocks in the wake of the market's steep rally should consider this advice from Warren Buffett.

Investors can always find buying opportunities in the market

Warren Buffett is one of the most successful investors in American history. He began buying shares of Berkshire Hathaway in 1962 and accumulated a controlling ownership stake by 1965. Under his leadership, Berkshire has evolved from a struggling textile mill into one of the most valuable businesses in the world with shares compounding twice as fast as the S&P 500 over a period of more than 55 years.

Buffett's patient, value-oriented investment philosophy played an important role in catalyzing that evolution. Berkshire is currently worth $880 billion, and a substantial portion of that value comes from its $370 billion stock portfolio. Buffett manages the vast majority of that total, which makes him (and Berkshire) an excellent case study for investors.

Buffett once wrote, "A simple rule dictates my buying: Be fearful when others are greedy, and be greedy when others are fearful." That widely quoted advice calls attention to a quirk of human nature. People overreact to good news and bad news, so stocks are often overvalued during bull markets and undervalued during bear markets.

However, Buffett and his co-investment managers, Todd Combs and Ted Weschler, have found buying opportunities in all market environments, including the current one. They bought shares of Sirius XM Holdings, Occidental Petroleum, and Chevron for Berkshire's portfolio during the fourth quarter of 2023, despite the increasingly rich valuation of the S&P 500.

Buffett's blueprint for success in the stock market

Buffett buys businesses with durable economic moats but only when shares trade at a discount to their intrinsic value. Buffett also picks stocks he feels comfortable holding for long periods of time. Every investor should follow that blueprint:

  • Understand the business before buying the stock: Knowledge is the cornerstone of any good investment decision. It never makes sense to buy a stock without first understanding the business. Doing so would be tantamount to gambling, and investors that treat the stock market like a casino are setting themselves up for trouble; the house will eventually win.
  • Look for businesses with a competitive advantage: Economic moats come in different shapes and sizes, but they generally amount to pricing power and cost advantages. Those qualities can arise from intellectual property, network effects, switching costs, and scale. For instance, Nvidia and Apple have pricing power due to patented technologies. Similarly, Visa and Coca-Cola benefit from cost advantages created by the vast scope of their businesses.
  • Consider valuation in the context of future growth: Determining the intrinsic value of a stock is more art than science. Buffett once quoted economist John Burr Williams: "The value of any stock, bond, or business today is determined by the cash inflows and outflows -- discounted at an appropriate interest rate -- that can be expected to occur during the remaining life of the asset." That quote refers to the discounted cash flow (DCF) model, a mathematically complex process that values a business based on future earnings. There are DCF calculators online, but the methodology is not infallible because investors must make assumptions regarding cash flow growth and the discount rate.
  • Hold good stocks for long periods of time: Investors should purchase stocks with a buy-and-hold mentality. To quote Buffett, "If you aren't willing to own a stock for ten years, don't even think about owning it for ten minutes." That does not mean investors should hold a stock even after losing confidence in the business. However, the market can be irrational over short periods because many investors trade on momentum and emotion. Time tends to weed out deviations from intrinsic value, and fundamentally sound businesses usually outperform in the long run.

Here's the bottom line: The S&P 500 has moved much higher over the past year, and the index does trade at a premium to its historical valuation, meaning many stocks are probably overvalued at their current prices. In other words, the current market environment is more greedy than fearful, so investors should be cautious -- but not so cautious that they miss out on opportunities.

Berkshire bought stocks in the fourth quarter, meaning Buffett and his team were able to find what they believe are good businesses trading at reasonable valuations. Investors who follow that blueprint have a good shot at making money in the long run.