The past three years have been a roller-coaster ride for investors in consumer electronics retailer Best Buy (NYSE:BBY). The stock collapsed in 2012 amid fears that the company could not compete with online retailers, nearly quadrupled in 2013 from the lowest point late in the previous year, and then crashed again early this year on skepticism regarding the company's turnaround. Since then, the stock has gained back some of what it lost, and it still sits nearly three times higher than the lowest point in 2012.

Bby Roller Coaster

Source: Yahoo! Finance

I bought Best Buy stock very close to that lowest point, as you can see from the chart above, and those shares have nearly tripled in value in less than two years. Here are a couple of important lessons I learned while riding the Best Buy roller coaster to some nice gains.

Don't panic when your stock falls
This is one of my favorite quotes from Warren Buffett: "Unless you can watch your stock holding decline by 50% without becoming panic-stricken, you should not be in the stock market."

During the nearly three years I've owned shares of Best Buy, the stock has declined by roughly 50% twice. The first time, the stock fell below $12 per share in late 2012, after I bought it months earlier for about $24 per share. The second time was after the massive run-up of 2013. The stock reached a high of roughly $44 per share, and I had sold a portion of my position at $39. I used that money to buy those shares back at a far lower price a few months later.

Buying low and selling high is a simple concept to understand, but in the face of incredible uncertainty, like that facing Best Buy two years ago, it's all too easy to let panic and fear override rational thought. Individual stocks fall by 50% all the time, and occasionally the entire market does the same.

A decline of this magnitude is often an opportunity, not a disaster. If your original reason for buying the stock is still valid after the plunge, the lower stock price is a gift. Only if something fundamental has changed about the company should you consider cutting your losses and running. Too many investors automatically do the latter.

I originally bought shares of Best Buy because it was the only large nationwide consumer electronics chain left standing, and I felt the threat from online retailers was overstated. Best Buy was still very profitable, backing out one-time items, and I felt I had a significant margin of safety at $24 per share. When the stock fell to half that, nothing had really changed. There was new management with a new plan, which I supported, but the key reason why I had bought the stock in the first place remained the same. At $12 per share, I felt like I was stealing.

When the world is against you, you're either very right or very wrong
You almost have to be a contrarian to do well in the stock market, because if you simply buy what everyone else is buying, you can't really do better than average. Sometimes, the sentiment surrounding a particular stock becomes either overwhelmingly positive or overwhelmingly negative, and this is when huge returns can be achieved.

Late 2012 was one of these times for Best Buy. The stock had been hammered all year, CEO Brian Dunn had abruptly resigned, and a long-shot buyout effort was launched by the company's founder. Articles like this one on Forbes.com were predicting the company's demise, and the turnaround plan from new CEO Hubert Joly had yet to bear fruit.

As it turned out, Best Buy survived, and Joly's plan appears to be succeeding. But the retailer was never in any serious threat of bankruptcy in late 2012. In the fiscal year ending in January 2013, after backing out one-time impairment and restructuring charges, Best Buy earned about $800 million in adjusted net income, and the company had $1.8 billion in cash sitting on the balance sheet after the holiday season. Best Buy's valuation based on these numbers was ludicrous.

Things could have certainly gone wrong for Best Buy, but the company was in a very different situation than the one competitor, RadioShack (NYSE:RSHCQ), is in today. On the surface, the two scenarios look similar. Both are troubled retailers struggling to compete against e-commerce, and both saw their stock prices plummet. But while I had a good reason to be contrarian when Best Buy hit its lows in 2012, given its profitability and balance sheet, I see no real reason to be contrarian when it comes to RadioShack. The retailer is plagued by massive loses, huge debts, and the absence of a viable plan, and RadioShack is an example of when being contrarian for the sake of being contrarian leads to disaster.

What now?
After tripling my money with Best Buy, I plan on holding on to the stock. I believe Best Buy is still undervalued, even after its huge run-up since late 2012, and the plan that Joly has in place seems to be working quite well. Best Buy has built up a fortress balance sheet, with more than $3 billion in cash and investments, and its online business is growing rapidly. While sales continue to fall, weakness in the consumer electronics industry is largely to blame, and Best Buy has at worst maintained its market share in recent quarters. Best Buy is now in a strong position to carry out the rest of its turnaround, and while quarterly results may be volatile, I like the company's chances in the long run.

Timothy Green owns shares of Best Buy. The Motley Fool recommends Apple, Google (A shares), Google (C shares), and Netflix. The Motley Fool owns shares of Apple, Google (A shares), Google (C shares), and Netflix. 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 Motley Fool has a disclosure policy.