This chart will tell you how to detect a bubble in the stock market. It's available at: http://www.bullandbearwise.com/SPEarningsChart.asp
As you see, the real S & P P/E went sky high during the housing bubble. Now it's down to where it was on September 30, 2007. It's still not down to historic norms, so the current bubble is still not completely deflated. If it starts going up again, it's time to get out of the market.
This chart is not be be confused with the annualized P/E chart for the S & P. That one uses old data over the previous year to come up with the P/E so it is late on predicting both the start and end of a bubble.