No matter what the market is doing, it's a great idea to keep an eye on the moves of Warren Buffett. He's proved his understanding of stocks over time and his ability to translate that into investing success. The top investor has sat at the helm of Berkshire Hathaway for nearly 60 years, and over that time period has helped drive a compounded annual return of about 20%. That far outshines the S&P 500 (^GSPC 0.27%), which delivered a 10% such return.
And during times of market uncertainty, it's particularly interesting to look to Buffett for guidance. Now may be one of those times -- with the S&P 500 lingering near record highs and as we start off a month that's historically been the worst for investors. What has Buffett been doing in recent times? Well, the investing giant has been a net seller of stocks quarter after quarter for almost three years.
In fact, his moves have resulted in a $344 billion cash pile at Berkshire Hathaway, and this may be seen as a warning to Wall Street that's ringing out loud and clear. Does this mean you should buy or avoid stocks during the potentially difficult month of September? Let's find out.

Image source: The Motley Fool.
Stocks in September
So, first, let's talk about the month of September. It's been the worst for investors over time, and this trend is confirmed if we look at recent data. Over the past five years, the S&P 500 only advanced once in September -- by 2% last year. The other Septembers resulted in losses of about 3% to 9%. If history is correct, we may be heading for another tough month that could lower the value of your portfolio, at least temporarily.
Now, let's move on to Buffett's warning. The billionaire never joins in big market movements. For example, if everyone is buying artificial intelligence (AI) stocks, Buffett won't be part of this crowd. He doesn't do this just to be contrary. Instead, Buffett prefers focusing on value stocks -- quality companies that may be overlooked by the general market today but have what it takes to deliver growth over the long run.
So, in recent quarters, as investors flocked to technology and growth stocks and the S&P 500 soared, Buffett bought selectively and grew his pile of cash, readying himself for future investment opportunities. Buffett's warning is essentially this: Stocks have become expensive, and as a result, the market could pull back at any moment.
We can see this through the S&P 500 Shiller CAPE ratio, today at levels it's only reached twice before since the S&P 500 launched as a 500-company index.
S&P 500 Shiller CAPE Ratio data by YCharts
What Buffett does in this investing environment
The Shiller CAPE ratio is a particularly sound metric because it measures a company's earnings per share, adjusted for inflation, over a 10-year period. And the current level shows that stocks, overall, are expensive, making this the sort of environment that Buffett approaches with caution.
Considering all of this, should you buy or avoid stocks during what generally is the worst month for the stock market? Like Buffett, we all should pay close attention to valuation and avoid buying stocks that look overvalued -- but this is an important rule to invest by at any time, whether the overall market is rising or falling. (Of course, there may be some exceptions. Aggressive investors might, for example, consider shares of a high-growth tech company that's trading for a steep valuation if the full long-term picture looks bright.)
Opportunities on the horizon?
Still, this doesn't mean we should avoid stocks altogether, and Buffett isn't telling us to stop investing either. Instead, his huge cash pile implies opportunities may be limited at the moment, in many cases due to high valuations. But here's the good news. If stocks actually follow the historical trend and decline in September, this may create opportunities -- so September may be a fantastic time for the bargain-hunting long-term investor to go shopping for stocks.
Buffett backs up this idea as we can see in a comment he once made: "The best chance to deploy capital is when things are going down."
After all, the overall market and quality stocks have shown over time that they don't remain in the doldrums forever. So, when you buy at a low point and hold on for a period of years, you could set yourself up for a big win.
All of this means that, yes, you should consider buying stocks during the worst month of the year -- as long as, like Buffett, you make sure the price is right.