This was predictable.

As stocks hit all-time highs and bonds begin to fall, retail investors are buying stocks and selling bonds for the first time in years.

This data from the Investment Company Institute shows the flows in and out of mutual funds:

Source: Investment Company Institute

This excludes ETFs and individual stocks. But TD Ameritrade tracks its client activity, and recently wrote: "Clients ramped up their equity market exposure as they were net buyers of equities and sold fixed income mutual funds and ETFs."

A quick reminder: For the market as a whole, money doesn't actually flow into or out of assets; there's a buyer and seller for every trade. What changes is the price of the most recent trade.

But we know that investors consistently play this dance the wrong way. They get excited when stocks rise and rush out to buy more, and sell with abandon when markets head down. Old justifications for staying out of the market melt into justifications for getting into stocks now. Josh Brown wrote yesterday:

Everybody is unmasked and shown for what they truly are: Performance-chasing children who grow resentful at the thought of anyone's portfolio outpacing theirs, no matter how much risk is being assumed. Screaming chimpanzees rattling the bars of their cages when the colors and lights start flashing.

"I know I said I wanted to treat this capital responsibly and tune out the noise-but why the hell don't I own those hot stocks that keep going up every day?"

Portfolio stewardship is great but that's not what you want when the market rallies. What you want is to beat that index when it goes up. What you want is an ego stroke, you want bragging rights and you want to be in the game, not watching it. It's only partially about the money, it's more about being right.

We've written about the hazards of buying high and selling low ad nauseum. But it's the most common mistake investors fall for. And while stocks probably aren't a bad buy at current prices, the destructive behavior of poor timing erases most of the long-term value markets offer over time. The average individual investor underperforms the S&P 500 (^GSPC -0.22%) by nearly six percentage points per year. Quarterly earnings, employment reports and head-and-shoulder chart patterns don't matter. This does. It is literally the most important investing topic that exists, and can't be discussed enough.

If you're one of the investors who's been sitting in cash or bonds for the last few years and just now wants to jump back into stocks, ask yourself two questions:

What are you going to do when the market falls again? Because it will. Unless you truly know that you'll act differently the next time stocks plunge, reassess what you're doing, or whether you have the temperament to be investing at all.

What are you goals? Is your goal to beat the market this month? This quarter? Over the next 10 years? Not at all? Is it to retire next year, or 30 years from now? Is it to outperform your brother-in-law? Are you doing it just for fun? Few ask themselves these questions, but how you answer them can dramatically change how you invest and think about market moves.

Investor Bill Bonner once said, "People do not get what they want or what they expect from the markets; they get what they deserve." Keep this in mind if you're shifting assets into the market now that stocks are at all-time highs.