BUT! There's always a 'but' right? That doesn't mean that you blindly throw money at index funds when they're grossly overpriced and that doesn't mean that you don't invest when it gets way undervalued. A new study from the research firm Dalbar shows that stock pickers for the most part lag the market. So what's an investor to do?
Well you can either blindly put everything into an index fund or you can pay a little bit of attention to the Shiller PE ratio. This has proven to the be the most "accurate" way in my opinion (and others) of showing how over or under priced the market is as a whole. Also in my opinion I think that Buffett has used something like this in the past as well. He's always said that you can't time the market, but if you look at his buying and selling patterns he's been out of the market at the peak and in the market fully (some times even leveraged) at the bottom. Unless you're lucky the only way to do this is to have some sort of valuation mechanism for the market. That or your instincts are awesome.
I like Shiller's PE ratio because it follows Benjamin Graham's valuation method for individual stocks. He just does it for the whole market. It's quite conservative and works well. The study found that you should underweight or overweight stocks by 30% if the ratio is in the top or bottom tenth of readings, and by 20% if it was in the next two-tenths. In other words scale up and down your holdings as the market becomes cheap or expensive. Going all in or all out of the stock market at once is not advisable and is counterproductive.
The stock market is getting high and I recently did some selling for this very reason. With that said I didn't sell everything and I personally think the market has a few more years before the big crash happens. This in turn makes it easier to get in and out of the market at the peaks if you're already still partially in it.