The S&P 500 -- along with its predecessor, the S&P Composite -- has only lost value in two 10-year periods dating back to 1926: once around the time of the Great Depression and again in the decade stretching from the peak of the dot-com bubble to the beginning of the Great Recession. That's it. While that goes to show the importance of diversifying your investments into multiple asset classes, it also goes to show the power of investing in stocks with a long-term mindset.

With that in mind, we asked three contributors at The Motley Fool for a stock they'd be willing to buy and hold for decades. Here's why they chose Repligen (RGEN -2.44%), Trex (TREX 0.20%), and TerraForm Power (TERP).

Several $100 bills rolled up and secured with a green ribbon tied in a bow.

Image source: Getty Images.

A 10-year return of 1,640%, with room for more

Maxx Chatsko (Repligen): Most investors have probably never heard of Repligen, but it's playing an integral role in the rise of the global biopharmaceutical industry. Rather than develop drug candidates through expensive and risky clinical trials, the company sells consumable equipment and chemical reagents required to safely and efficiently manufacture biologic drugs in volumes suitable for small clinical trials all the way up to blockbuster drug franchises.

Business is booming. Repligen delivered $131 million in revenue and $22 million in operating income in the first half of 2019, marking year-over-year increases of 42% and 117%, respectively. Part of the growth has been driven by increasing demand for its products, although a penchant for acquisitions has certainly played a part. The business is reaping rewards from acquisitions of the past few years and looking to integrate one of its largest ever: the $240 million buyout of C Technologies.

Management's willingness to gobble up smaller businesses in the space to augment Repligen's broad offerings has clearly treated shareholders well over the years. But perhaps more important is the company's ability to remain a few steps ahead of the fast-moving currents in biomanufacturing. That shows that management has high visibility into where the field is heading and to what pain points customers will next seek solutions, which is a key consideration for investors with a long-term mindset that doesn't show up on financial statements.

Considering that the business exited June with $209 million in cash and added another $290 million in cash since July, there could be more acquisitions or organic product launches on the horizon. That said, integrating C Technologies will weigh on margins in the short term, judging from the latest full-year 2019 guidance, but perhaps that'll create an opportunity for investors to buy shares at a lower entry point.

An origami display of balloons holding dollar signs.

Image source: Getty Images.

A sustainable growth business 

Jason Hall (Trex): On the surface, it would be easy to assume Trex is a highly cyclical business driven by housing sales. That's not exactly the case; the vast majority of its business comes from home improvement projects, not new construction. In reality, Trex could be one of the great growth stocks of the next several decades, built on the strength of a core business that's appealing to homeowners both young and old. 

Trex manufactures decking that's made from scrap wood and plastic, much of which would otherwise end up in landfills. That's appealing to many people, and something that should play an increasingly bigger role in spending decisions by homeowners. Simply put, millennials will drive the housing and home improvement market for the next decade-plus, and they prioritize environmentally responsible products far more than their older cohorts do. 

But that doesn't mean Trex is a niche, tree-hugger product that only appeals to environmentalists. To the contrary, one of Trex's biggest selling points is that it costs almost nothing to maintain over its 25-year life, while a wood deck would require thousands of dollars in cleaning and wood treatment chemicals. That's why plenty of people are happy to pay twice as much for Trex decking, on average, than wood. That upfront expense more than pays off with lower maintenance costs, and physical effort. 

Here's why Trex is worth buying now to hold for decades: More than 80% of deck volume sold in North America is still wood, meaning there's a massive opportunity for Trex to continue taking market share. The company commands more than half the alt-wood decking share and has by far the largest distribution and most-recognizable name. 

Put it all together, and you have the rare combination of a dominant market leader in its segment with an addressable market that's 10-times bigger than its current business. And that's just in North America. 

A row of wind turbines in a field.

Image source: Getty Images.

This renewable-energy stock has a bright future

Matt DiLallo (TerraForm Power): TerraForm Power is building a business to create value for investors over the long haul. For starters, it focuses on the renewable-energy sector, which is in the early stages of a multi-decade growth phase as it slowly weans the global economy off fossil fuels. TerraForm therefore takes a long-term approach to how it runs its business.

For example, instead of playing the short-term power market by trying to get the best price for the energy it generates, TerraForm sells its electricity under long-term contracts. Currently, the company has agreements in place for 95% of the power it produces that have an average remaining term of 13 years. That approach enables the company to generate predictable cash flow no matter the market conditions.

It also allows TerraForm to provide investors with a much longer-term outlook of its growth prospects than most other companies. While many companies will forecast the next quarter or year, TerraForm's current projection stretches through 2022. During that timeframe, the company expects to grow its cash flow at a fast enough pace to increase its 4.8%-yielding dividend at a 5% to 8% annual rate.

Given TerraForm's focus on the long term, it's an ideal stock to buy and hold over the next few decades.