Warren Buffett has proven his ability to score investment wins through good market times and bad. At the helm of Berkshire Hathaway, he's helped deliver a compounded annual gain of nearly 20% over 58 years, soaring past the S&P 500's 10% compounded annual increase during that time period. That's why investors tend to take notice of Buffett's investing moves and what he has to say about investing at a particular point in time.

In recent times, Buffett's actions may speak louder than words. The Oracle of Omaha, as he's often called, recently made a very significant move -- one that investors shouldn't ignore. In fact, some may even see this action as a warning for all of us. As indexes soar, does Buffett know something that Wall Street doesn't? Let's find out.

Warren Buffett is shown at an event.

Image source: The Motley Fool.

What's driving investor optimism

First, though, let's take a quick look at this year's general market environment. All three indexes are heading for big-time gains as a lower interest rate environment and excitement about artificial intelligence (AI) stocks have driven investor optimism. The Federal Reserve cut interest rates twice this fall, and the idea is a lower rate environment eventually will boost consumers' buying power and make it easier for companies to borrow to support growth.

As for AI, this newish technology has the potential to revolutionize many business areas and our daily lives, resulting in greater efficiency and lower costs for many companies as well as game-changing products and services that could supercharge revenue. Analysts forecast that today's $200 billion AI market will reach $1 trillion by the end of the decade. So, investors have been piling into top AI players, and that's helped indexes climb. The S&P 500, the Nasdaq, and the Dow Jones Industrial Average are heading for increases of 25%, 26%, and 18%, respectively, this year.

But amid all of this excitement, Buffett has made a particularly sobering move. In the third quarter, he cut his position in two of his favorite stocks, Apple (AAPL -1.32%) and Bank of America (BAC -0.47%), by 25% and 23%, respectively. That's after already reducing his Apple position by nearly 50% earlier in the year. Apple still remains Buffett's biggest position, while Bank of America dropped from its spot as the second-largest holding to the third largest behind American Express.

"Casino-like behavior"

In Buffett's 2023 shareholder letter, the billionaire investor also spoke of the "casino-like behavior" he's observed in today's stock market, a point that suggests Buffett is becoming more cautious. This brings to mind Buffett's words in his 2000 letter to shareholders in which he warned that after making "effortless money," investors may behave like Cinderella at the ball, "overstaying the festivities."

Does this mean that Buffett knows something Wall Street doesn't, and the market may be heading for a downturn? Not necessarily. First, it's important to keep in mind that Buffett earlier this year mentioned his interest in locking in gains on some positions at the current capital gains tax rate. So, the Apple and Bank of America moves don't suggest a loss in faith in those companies.

But the top investor's recent move and words over time should prompt investors to carefully take a look at valuations in today's market environment. And here, we can turn to the S&P 500 Shiller CAPE ratio, an inflation-adjusted, valuation measure that considers companies' earnings over a 10-year period in relation to price.

One of the market's priciest moments in time

This measure is at more than 35 today, a level it's only reached -- and even surpassed -- two other times since the S&P 500's launch as a 500-company index in the late 1950s. So, it's clear the market as a whole is at one of its most expensive levels ever.

S&P 500 Shiller CAPE Ratio Chart

S&P 500 Shiller CAPE Ratio data by YCharts.

All of this means that, like Buffett, investors should approach the market carefully, paying attention to each stock's valuation before buying instead of following the crowd into a particular player that may have had a good run but could be too expensive right now. This doesn't mean you should stop investing or worry about an eventual market downturn. The stock market will go through difficult times now and then, but here's the good news: If you buy quality stocks for a reasonable price and hold on for the long term, shorter-term market cycles won't impact your returns by very much.

So, today's warning from Buffett doesn't mean you should stop investing. Instead, it's just a reminder to choose stocks wisely and stay focused on the long term -- and that's how, like Buffett, you may set yourself up for a major win.