The Dow Jones Industrial Average (^DJI 0.30%) and the S&P 500 (^GSPC 0.97%) are trading just below their all-time highs this afternoon. Many investors are wondering if this is still a good time to buy. By many measures, the stock market is overvalued. That assessment is backed up by one stock market indicator that Warren Buffett uses to determine whether the market is expensive or cheap. Read on to find out more.

Stock market today
While opinions vary, there have been many anecdotal signs lately that the stock market is overheated.

The average first-day pop of an IPO this year is 17%, the highest level in 10 years. New companies are being valued on fuzzy metrics. Twitter (TWTR) is a good example, with its 73% first-day pop more focused on its user data than its advertiser data.

Corporate profit margins are at all-time highs, and earnings are not growing. The S&P 500 is rising on earnings-multiple expansion, rather than earnings growth, and it looks overvalued.

The cyclically adjusted P/E ratio (a.k.a. the Shiller P/E) is at 25 -- about 50% 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. This indicates that they do not see opportunity in the marketplace currently and would rather be in cash to take advantage of future opportunities.

All the while the U.S. economy is growing slowly on the back of the Federal Reserve, which is pumping $85 billion a month into the market and now has a balance sheet of $4 trillion.

The question remains whether the market is undervalued, fairly valued, overvalued, or perhaps in a bubble. I've written before of why I think the stock market is overvalued, but let us turn to Warren Buffett.

Warren Buffett's favorite market metric
In two separate interviews in 1999 and 2001 Buffett explained to Fortune magazine's Carol Loomis that determining whether the market is expensive or cheap doesn't have to be complicated. The metric Buffett uses is:

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, or GDP. Gross national product measures the value of goods and services that a country's citizens produce regardless of where they live. This includes the value of goods and services that American companies produce abroad.

So how do you tell if the stock market is expensive? Buffett went on to explain: "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?
One way to calculate the market value of all publicly traded securities is by adding the total market capitalization of the New York stock Exchange to the total market capitalization of the Nasdaq.

The market capitalization of the stock markets is reported monthly by the World Federation of Exchanges. At the end of October, the total market capitalization of U.S. markets was $22.9 trillion. The S&P 500 has risen 1.5% since then.

To find GNP, the Federal Reserve Bank of St. Louis has a great website where you can find most U.S. economic data. However, GNP is not reported until the second estimate of GDP, which comes out on Dec. 5. The most recent data for GDP for third-quarter 2013 is $16.86 trillion. GNP has averaged $250 billion more than GDP in the past six quarters, so we can project third-quarter 2013 GNP at $17.1 trillion.

Dividing the total market capitalization by GNP gives us a percentage of 134%. That is in the 94th percentile of results over the past 60 years and well above the 60-year average of 78%, indicating the market is overvalued.

Foolish bottom line
While I believe the stock market is overvalued, opinions differ.

Federal Reserve officials, including soon-to-be Chairwoman Janet Yellen and San Francisco Fed President John Williams, have said in the past two weeks that they do not believe the market is overvalued.

With the Federal Reserve committed to low interest rates and pumping money into the economy through quantitative easing, who knows how high the market can go. Predicting where the broad market will go in the short term is a game for fools (with a lowercase "F"). Stocks can always get more overvalued. When things get frothy, it's worthwhile to build up some cash on the side for when prices inevitably fall.

The Motley Fool has always taught that Foolish (capital "F") investors don't invest in the broad market. We invest in great companies at good prices, continue to educate ourselves, and hold on to our great companies over the long term. The market will fluctuate (sometimes massively), but great companies will win out over the long run.