Everyone knows that the worst time to sell is after the market has already crashed. Giving in to fear just when stocks are near their lows is just about the worst mistake you can make with your portfolio.

By contrast, the other side of the fear versus greed equation doesn't get a lot of attention. It can be just as detrimental to your portfolio, though, so before you get swept up in the bullishness that you'll find throughout the stock market today, be sure to take a gut check and make sure you won't do something you'll regret later.

The bull's back, baby!
If you haven't seen the headlines yet, you will soon enough: Stocks closed yesterday at multiyear highs, with the Dow Jones Industrial Average (INDEX: ^DJI) climbing to its highest level since late 2007. The immediate cause for celebration came from Europe, where the continent's central bank finally caved pressure to institute a program allowing for purchases of sovereign bonds from struggling eurozone member countries.

The impact was immediate and global in scope. European stocks gained roughly 3%. Many companies in those countries helped most by the European Central Bank's decision made even stronger moves. Spanish telecom Telefonica (NYSE: TEF), for instance, jumped more than 5%, as investors clearly believe that a healthier Spain means better prospects for the geographically diversified company.

The speed with which gains spread around the world made it clear just how threatened investors have felt by Europe's drag on the global economy. In Brazil, Vale (NYSE: VALE) climbed more than 4% on prospects that a healthier Europe could reignite demand for the natural resources it provides. Solar-energy giant First Solar (Nasdaq: FSLR) soared more than 7% on apparent hopes that European solar orders might rise again if the economy there stops getting weaker. Even Ford (NYSE: F), which has suffered from poor sales in Europe for some time, joined the party, gaining almost 4% in light of a new strategy to recover its strength on the continent.

With all this good news, you might feel compelled to invest all your spare cash in stocks now before the bull-market train leaves you behind. Yet although some investors may be well-served by getting some of their money into the stock market, you shouldn't buy just because everyone else is.

Yes, panic-buying does exist
The impulse to buy after a breakout day like yesterday can feel almost overwhelming. Particularly for those who have been waiting for the other shoe to drop ever since the market hit its bottom in early 2009, the nearly uninterrupted march upward for stocks has been nearly unbearable to watch. Thanks to dividend payments, many of those who stayed in stocks throughout the financial crisis have actually seen their portfolios go up in value from their precrisis levels. Those who locked in losses haven't been so fortunate.

Before you buy stocks now, though, let me suggest you do a couple of things first:

First, take a step back and evaluate your entire investment portfolio. Tally up all the investments you own and figure out how your money is allocated across different types of assets. Then think about what your ideal investment mix would look like, based on your risk tolerance and other factors like age and net worth.

After you've gathered all the information you need, then look at whether making trades is warranted in order to get your portfolio back in line with where it should be. For some, that will mean buying stocks. Yet many who have held and added to stock positions over the past three years may find that they have too much of their money in stocks and should therefore trim their stock exposure -- taking advantage of new highs to sell high.

Moreover, if you do determine that you should buy stocks, don't just buy any stock. Even after the recent run-up, there are still many stocks that trade at reasonable valuations. By focusing on them, you can give yourself a margin of safety, even with the broader averages at new highs.

Keep calm and Fool on
In many ways, it's harder to stop yourself from buying stocks at record highs than to keep from selling at record lows. But both situations require emotional discipline. If you can keep yourself under control, you'll have mastered one of the most difficult aspects of investing.

Ford's new strategy in Europe means a lot to the prospects for the entire company. Find out how Europe fits into the automaker's broader strategy by reading the Motley Fool's premium report on Ford today. With a year's worth of free updates, you'll stay up to date on the latest goings-on with the Blue Oval.