I like to think I'm a pretty solid investor these days, but a big reason for this is that I've learned from many mistakes along the way. All investors make bad judgement calls at one time or another, but it's what you learn from your mistakes that's the most important thing.

One big mistake that I've made a few times throughout my investing career is selling great stocks too early despite believing in the underlying companies' businesses over the long term. Three stocks in particular stand out as examples of why selling too early can cost you thousands in potential gains.

Couple hiding under a blanket with scared expressions.

Image source: Getty Images.

Be careful about trying to "lock in" your gains

I often refer to my 2011 investment in Tesla Motors (TSLA -3.08%) as both my best and worst investment of all time. I more than doubled my money in a short amount of time but sold the stock way too early.

Here's the short version of how it happened. I bought Tesla shortly after its IPO in 2011 for about $23 per share. At the time, the company's sole product on the market was the Tesla Roadster -- an extremely impressive vehicle, but as a mainstream car company, Tesla was largely unproven.

Over the next year or so, the Tesla Model S began to gain traction and the stock steadily rose. In late 2012, the long-anticipated Tesla Model S was named 2013's "Car of the Year" by Motor Trend, and the stock continued to surge. I ended up selling my shares at about $58 a few months later, even though I still believed strongly in Tesla's product, more than doubling my investment in a little over a year.

At the time, I thought I made a smart decision. However, over the next couple of years, the Model S continued to be the recipient of praise and continued to sell better than anyone had initially expected. And more importantly, the road map to becoming a major contender in the auto industry began to emerge. As I write this, Tesla's stock price is over $300.

TSLA Chart

TSLA data by YCharts.

Cashing out on a big trend too early

Now, you might think that my knee-jerk sale of Tesla would have been the last time I did that, but unfortunately, there was one more similar situation.

Sensing that the OLED display market was poised to explode over the next decade or so, I bought shares of Universal Display (OLED 2.18%) in 2013 for just under $25. Several months later, shares were trading for about $49, and I decided to cash in -- even though I didn't think the OLED market, or Universal Display, was even approaching its potential.

Well, the company continued to perform well, with the stock peaking at $209 just a few months ago. Although Universal Display has since fallen to about half of its peak value, fueled by fears that Apple will decide to manufacture its own OLED displays, I still would have doubled my investment again had I held on.

OLED Chart

OLED data by YCharts.

Why short-term trading isn't the way to go

I started investing in the early 2000s, and like many new investors, I made a serious rookie mistake. Specifically, in the early days of my investing career, I was in the mindset that the best way to make money in stocks was to move in and out of stocks frequently to try to time the market, rather than focusing on the long-term reasons to buy.

One example was biotech company Repligen (RGEN -4.17%), which I bought in 2004 at a penny-stock price of just $2.53 per share. Repligen is a biopharma supplier, selling products that are required to manufacture biologic drugs.

At the time, I liked what I was seeing from the company, and its valuation seemed too cheap to ignore. Unfortunately, I was hoping for a jump to, say, $3, and then I would be on to the next big adventure. Repligen's share price ended up going nowhere for a few months, and I ended up selling my 1000 shares at slightly more than I paid for them, despite wholeheartedly believing in the company's long-term potential.

Here's the big lesson. Fourteen years later, Repligen has grown to be a major player in its industry, and the stock trades for about $37.50. My 1,000 shares, which I impatiently sold for just over $2,500 would be worth $37,500 today -- a gain of about 1,400%.

RGEN Chart

RGEN data by YCharts.

The moral of the story

To be clear, I'm not trying to discourage you from selling stocks altogether. There are certainly plenty of good reasons to unload a stock position and move on. Even the greatest long-term investors, such as Warren Buffett, sell stocks occasionally, and for a variety of perfectly valid reasons.

However, one of the most important investing lessons I've learned the hard way, and hopefully you can learn from my mistakes, is not to sell for the wrong reasons. If you believe in a company's long-term potential, and your initial reasons for buying the stock still apply, I strongly suggest that you think twice before cashing in.