Warren Buffett's Berkshire Hathaway (BRK.A -0.23%) (BRK.B -0.28%) had $147 billion in cash, cash equivalents, and short-term investments on its balance sheet as of June 30 -- a treasure chest of investable capital. However, the company was still a net seller of stocks through the first half of the year. In fact, Berkshire reported $21 billion in net equity security sales through the quarter ended in June, a dramatic reversal from its $45 billion in net purchases during the same period last year.

The unsettling implication is that the CEO and his fellow investment managers Ted Weschler and Todd Combs see the stock market as overvalued. And historical data supports that assertion. According to FactSet, the benchmark S&P 500 (^GSPC 0.32%) currently trades at 18.8 times forward earnings, a premium to the 10-year average of 17.5 times forward earnings.

The S&P 500 is still up 18% year to date on signs of economic resilience, but stock market momentum fizzled in August, and bearish sentiment reached a three-month high. So, investors may be wondering whether now is a good time to buy stocks. To answer that question, here's an important insight from Berkshire's financial filings, followed by some sensible investing advice from Buffett himself.

Berkshire Hathway buys stocks through thick and thin

Readers should not assume that Warren Buffett cannot find any compelling buying opportunities in the stock market. While Berkshire has been a net seller of stocks this year, the company still purchased $7.4 billion in equity securities through the quarter ended in June and spent another $5.8 billion on share repurchases.

A similar pattern exists in the past. There has not been a single year that Berkshire has avoided stocks entirely in the last three decades. Buffett has found buying opportunities through bear and bull markets -- in times of financial crisis and economic prosperity -- and there is no reason to think that has changed.

So, here's the question: Where should investors put their money right now, given that many stocks trade at a premium to their historical valuations?

Buffett has a simple blueprint for picking good stocks

In his 1977 letter to Berkshire shareholders, Buffett condensed his philosophy on picking stocks into four bullet points: "We want the business to be (1) one that we can understand, (2) with favorable long-term prospects, (3) operated by honest and competent people, and (4) available at a very attractive price."

All four ideas warrant further discussion. First, investors should never buy a stock without understanding the business. Smart decisions require a good grasp of fundamentals like how a business makes money, how it fits into the broader industry, and how the industry might evolve in the future. Investors who act without that information are gambling. Even worse, they are gambling against well-informed financial professionals with far more resources.

Second, investors must find stocks with favorable prospects for long-term growth. That may sound obvious, but simply throwing money at businesses in growing industries will not suffice. Favorable long-term growth prospects cannot exist without a durable competitive advantage. To quote Buffett, "A truly great business must have an enduring 'moat' that protects excellent returns on invested capital."

Third, investors should prioritize companies with good leadership. No metric measures stewardship directly, but indirect indicators, like spending decisions, financial trends, and market share, provide insight into how well a business is managed. Investors should also read transcripts from quarterly earnings calls. It's an opportunity to hear management provide off-the-cuff answers to questions posed by Wall Street analysts.

Fourth, investors must always consider valuation. The best business in the world would be a bad investment at the wrong price. So, investors should perform a discounted cash flow (DCF) analysis to determine whether a stock trades at a discount to its intrinsic value. As a caveat, DCF calculations are mathematically complex, but there are plenty of good online calculators.

Here's the bottom line: The current market environment warrants caution, but stocks that meet the four criteria outlined by Buffett are always worth buying.

Buffett is a believer in the S&P 500 index fund

Researching stocks is time-consuming and often tedious, and there is no shame in choosing a less complicated investment strategy. In fact, Buffett has often evangelized the benefits of consistently buying an S&P 500 index fund. Doing so allows investors to diversify capital across hundreds of stalwart businesses that form the foundation of the U.S. economy. Buffett says those businesses "are bound to do well" in aggregate over time.

Historical data backs that conviction. The S&P 500 has returned 10% annually over the last 30 years, and there is no reason to expect a different outcome over the next 30 years. Better yet, the index has produced a positive return over every rolling 20-year period since its inception in 1957. So, even if the stock market is slightly overvalued today, investors who patiently hold an S&P 500 index fund are virtually guaranteed to profit in the long run.