A Goldman metric shows stocks extremely overvalued

Traders work in the Goldman Sachs booth at the New York Stock Exchange
Scott Eells | Bloomberg | Getty Images

Extreme valuations in stocks should cause investors to think twice before chasing the rally at these levels, Goldman Sachs cautions.

"S&P 500 stands at an all-time high and the median stock's P/E is at the 99th percentile relative to the past 40 years," Goldman's market strategist David Kostin wrote in a note to clients Friday.

Last week, the set a new intraday all-time high, surpassing its previous peak reached in May 2015, with stocks up a whopping 15 percent in the past six months.

More traditional valuation measures show extreme levels, too. The S&P 500 trades at a forward P/E of 17.6 times, ranking the current levels in the 89th percentile since 1976, according to analysis by the investment bank.