So, the markets are exploding and like me your thinking about potentially many things:
1: finding a rock to hide under
2: wishing you had taken more profits sooner
3: had a magic crystal ball that told you when such events like the past few days would be coming.
How could you have avoided this? Well, honestly there really isn't any way to avoid such wacky market insanity. The best way to deal with a situation like this is to BUY BUY BUY. This of course requires that you have some cash left... And being the foolish/greedy fellow I try not to be, I had been "all-in" for quite some time now.
Thankfully some of my more recent purchases were protected by using "trailing-stops" which got me out at a modest profit rather than riding them down to the bottom. However, the trailing-stop is tricky. I've often lost money on the bounce after a stop has been triggered. So, set them with care, or be prepared to reach for the bottle of anti-acid when we have days like the past few.
In the short term, I can still see rocky days ahead. The S&P downgrade of USA is strangely prudent in a sick kind of way. The USA has been riding a AAA credit rating for the past 71 years and I suspect this has made them fiscally complacent thinking they could do no wrong. This is perhaps the kick in the pants they need to get their fiscal house back in order. The sad reality though is that rampant conservatism has crippled the government. Unable to move forward to address the NOW as well as the tomorrow.
In the short term if you're down and still like the companies you're holding, then by no means sell them. If you still like them, they probably look even better now at the current market prices. So if you do have spare cash, this is the time to buy.
If you can in the next few weeks/months take some profits and keep some cash on the sidelines... There will be more delicious buying opportunities in the near future. (Read: ugly days on the market)
Also, due to the nature of interest rates, I have largely ignored bonds in my portfolio. This probably a good time for all of us to start thinking about it. If you hold bonds, now would be a good time to sell them and buy some stocks at bargain prices. If you don't, then this would be a good time to start to VERY slowly accumulating some. Preferably in tax sheltered accounts since interest is generally taxed at the highest rate. And by slowly, I mean SLOWLY. Bond prices will fall as markets recover. It's just nice to have some bonds to give you some new cash every month/quarter AND have something to sell when markets tank so you get the cash you need to take advantage of the current discounts.