The past two years have been very kind to most stock investors. But often, you don't get immediate gratification from the stocks you buy. In those cases, it can be tough to watch your stocks languish while the rest of the market is going up a lot faster. When that happens to you, should you dump those stocks and move to other, better-performing alternatives, or should you stay the course and hope that other investors eventually recognize the attractiveness of the investment you discovered earlier than the crowd?

Being early to the game
The rally from the March 2009 lows surprised many investors for a number of reasons. The most obvious was just how big the rally was; in just a matter of months, the S&P 500 had bounced more than 50%, and it eventually posted a gain of more than 70% by the first anniversary of the bottom.

Of course, not every stock rose in lockstep with the S&P 500. Plenty of stocks did far better. Ford (NYSE: F), for example, posted far stronger gains as it managed to avoid the bankruptcies that its Big Three competitors General Motors and Chrysler faced. Similarly, Las Vegas Sands (NYSE: LVS) escaped what many seemed to believe would be the death of Las Vegas as a travel destination, thanks in part to success in Macau; and Sirius XM (Nasdaq: SIRI) took advantage of the desperation financing it got from Liberty Capital and confounded skeptics by growing its subscriber base and returning to competitive status.

On the other hand, some stocks languished. For instance, after holding up reasonably well in the run-up to the financial crisis, MetroPCS fell sharply as it suffered from huge amounts of competition in the lower-end mobile industry. Others, such as Borders Group, fell because of stock-specific pressures that proved insurmountable for their struggling businesses.

Slow but steady wins the race
But just because a stock doesn't rise as quickly as the early winners in a market rally doesn't mean they're doomed to failure. Take a look at these four stocks:

Stock

Return 3/9/2009 to 3/9/2010

Return Since 3/9/2010

Tesoro (NYSE: TSO) 8.9% 99.1%
Stericycle (Nasdaq: SRCL) 17.4% 68.2%
AutoZone (NYSE: AZO) 11.9% 66.9%
Sunoco (NYSE: SUN) 10.0% 51.0%

Source: Capital IQ, a division of Standard & Poor's.

As you can see, these stocks started out slowly during the rally. In the case of Sunoco and Tesoro, low oil prices and even lower revenue on refined profits made the refinery stocks look unattractive. But later on, even as oil prices returned to triple-digit levels, prices on products such as heating oil and gasoline climbed even more strongly, boosting margins and making these businesses look very strong.

With Stericycle, a big overhang of debt kept some investors away early in the rebound even as the credit markets started returning to normal. But as the company's dominant role in medical waste collection and disposal became more evident, the stock has attracted a stronger following. Similarly, while investors locked in on hot stocks, companies like AutoZone that produced impressive returns on capital and earnings growth waited patiently for others to discover them.

Don't give up
All this goes to show that when you've done research and found a stock that you believe has promise, it can take time for your investing thesis to play out. If you dump your best ideas just because they don't show immediate results, then you may well miss out on huge gains later on.

It can be hard to maintain faith in your investing judgment when the market seems determined to move against you. Eventually, though, if the companies you choose perform well financially, those strong results will show up in their share price -- and you'll reap the benefits. So long as nothing happens to contradict the reasons you bought a stock in the first place, you'll probably be better off sticking with your picks and waiting for the rest of the investing world to pick up on what you found early on.

And if the stocks above still look interesting to you, add them to your watchlist and keep an eye on them going forward.

All Fool contributor Dan Caplinger needs is a little patience. He doesn't own shares of the companies mentioned in this article. General Motors is a Motley Fool Inside Value pick. Stericycle is a Motley Fool Rule Breakers recommendation. The Fool owns shares of Ford, which is a Motley Fool Stock Advisor choice. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Fool's disclosure policy plays Guns N' Roses on its new iPad every hour on the hour.