When the market's heading south, most investors think only of how to preserve their money. Yet the right time to protect against yourself against risk is when you've taken on the most of it -- namely, when your stocks are soaring.

Unwittingly, many investors have seen the risk levels in their portfolios rise substantially over the past year. How did it happen? All they did was buy and hold stocks that have since seen some amazing gains. Yet for those who don't take any action to protect themselves and their paper profits, the future may prove surprisingly dire.

Learn from history, or repeat its mistakes
Countless times in the past, investors have seen amazingly profitable situations turn on a dime. Consider just a few:

  • Around the middle of 2008, fertilizer stocks were red-hot. Both PotashCorp (NYSE: POT) and Mosaic (NYSE: MOS) had seen their stocks triple over the preceding 12 months, and there seemed to be no end in sight for the industry's promise. Yet when those companies dealt with the double-whammy of collapsing agricultural commodity prices and the overall market meltdown, their stocks dropped sharply -- and while both companies have recovered nicely, neither has approached its former highs since.
  • During the same time period, oil prices hit their peak near $150 per barrel. Oil giants ConocoPhillips (NYSE: COP) and ExxonMobil (NYSE: XOM) earned record profits during the third quarter of 2008. Yet when oil prices collapsed at the end of the year, those profits largely evaporated -- and so did shareholders' stock gains.
  • Back in the roaring 1990s, the world seemed divided into two groups. Technology firms seemed to be on top of the world, with Cisco Systems (Nasdaq: CSCO) just beginning to cement its place as the enabler of the Internet. Meanwhile, so-called "old economy" stocks were seen as has-beens, with many criticizing Berkshire Hathaway (NYSE: BRK-A) (NYSE: BRK-B) CEO Warren Buffett for staying away from pumped-up tech stocks. Yet even though Cisco has in fact realized much of the Internet's potential, Berkshire's stock has been the better investment over the past 10 years.

Now, of course, the obvious move would have been to dump high-flying stocks entirely before they came crashing down to earth, and to replace them with beaten-down value stocks that were prone to rise. Yet that would have required perfect timing.

Second-best: Stay simple
In contrast, you can easily rebalance your portfolio on a regular basis. That means selling part of your position in top-performing stocks, and beefing up your holdings of investments that you still believe in, but which haven't done as well. Given that investments tend to cycle in and out of favor, this strategy not only protects your profits, but can also increase your overall returns.

The nice thing about rebalancing is that you'll almost always sell some of your shares near market tops. Of course, you may also end up selling part of your position long before a stock tops out, which means you'll have left some potential profits on the table. If you've tapped into a long-term winner like Green Mountain Coffee Roasters, that can turn out to be a disaster. Still, that's a trade-off that many are willing to make in exchange for a more stable portfolio.

Rebalancing is important not only for stocks, but also for your entire portfolio. As Foolish fund expert Amanda Kish recently told subscribers to the Fool's Rule Your Retirement service, an annual rebalancing to get your asset allocation back in line with your long-term strategy can mean the difference between holding onto your gains versus seeing them all slip away.

It may not feel right to let go of investments that have done so well for you. But it does give you the chance to explore even more attractive investments -- or to preserve cash for a time when valuations on the stocks you like have come back to more reasonable levels.

Don't miss out
If you haven't rebalanced your portfolio in a while, take a look and see where you stand. By rebalancing now, you can lock in some of your gains of the past year, and avoid the risk of suffering bigger losses if and when stocks suffer a correction.