The Dow Jones Industrial Average (DJINDICES:^DJI) and the S&P 500 (SNPINDEX:^SPX) are trading just below their all-time highs, and investors are wondering if this is still a good time to buy. Well, by many measures, including a market indicator that Warren Buffett uses, the market is overvalued. Let's see why.

The market today

So is the market overheating? Consider:

The average first-day pop of an IPO is 18%, the highest level in 10 years, even if the newly public companies are unprofitable and being valued on fuzzy metrics. Coupons.com is a good example: It's never posted a profit, yet it enjoyed an 85% first-day run-up and sports a price-to-sales ratio of 9.

is a good example: It's never posted a profit, yet it enjoyed an 85% first-day run-up and sports a price-to-sales ratio of 9. Corporate profit margins are at all time highs, but earnings aren't growing. The S&P 500 is rising on multiple expansions in earnings and looks overvalued.

Individual investors' asset allocations to stocks are near their highest levels since September 2007, at 66.9%, according to the American Association of Individual Investors.

Investors are using leverage at levels not seen since the last bubble to juice their returns, with margin debt as a percentage of the economy at a dangerous high.

The cyclically adjusted P/E ratio (the Shiller P/E) is at 25.8, 56% above its historical average of 16.5.

Respected investors including Jeremy Grantham, Wally Weitz, Donald Yacktman, Steven Romick, and Seth Klarman are building large cash positions.

The U.S. economy is growing slowly on the back of the Federal Reserve, which is pumping $65 billion a month into the market and now has a balance sheet of $4.2 trillion. Meanwhil,e the world economy is growing slowly on the back of China, which looks like it's in the late stages of a credit bubble.

So is the market is undervalued, fairly valued, or overvalued? Or are we in a bubble? I've written before of why I think the stock market is overvalued, but let's now turn to Warren Buffett.

Buffett's favorite market metric

In interviews with Fortune in 1999 and 2001, Buffett said that determining whether the market is expensive or cheap doesn't have to be complicated at all. His metric:

The market value of all publicly traded securities as a percentage of the country's business -- that is, as a percentage of GNP. The ratio has certain limitations in telling you what you need to know. Still, it is probably the best single measure of where valuations stand at any given moment.

Basically, Buffett divides the total market capitalization of the U.S. stock market by gross national product, or GNP. Not to be confused with gross domestic product, GNP measures the value of goods and services that a country's citizens produced regardless of where they live -- including what American companies produce abroad.

So when does the metric tell whether the stock market is expensive? Buffett again:

If the percentage relationship falls to the 70% or 80% area, buying stocks is likely to work very well for you. If the ratio approaches 200% -- as it did in 1999 and a part of 2000 -- you are playing with fire.

Where is the stock market trading today?

At the end of February, the total market capitalization of U.S. markets, as reported monthly by the World Federation of Exchanges, was $24.6 trillion. The S&P 500 has risen 0.5% since then.

The Federal Reserve Bank of St. Louis, meanwhile, includes most U.S. economic data, though we won't get a report on GNP until the second revision of GDP on March 27. The most recent GDP data we have, for Q4 2013, is $17,080 billion. GNP has averaged $250 billion more than GDP for the past four quarters, so we shall assume Q4 2013 GNP is $17,107 billion.

Dividing the total market capitalization by GNP gives us a percentage of 142%, which, according to Buffett, indicates that the market is overvalued.

Foolish bottom bine

While I believe the stock market is overvalued, opinions differ. But with the Federal Reserve committed to low interest rates and pumping money into the economy, who knows how high the market can go? One thing is fore sure: It's getting harder and harder to find great companies at good prices.