If you're looking for stocks to buy, high-growth industries and major secular trends are great places to start your research. Cloud computing and digital advertising have already reshaped the world, creating significant wealth in the process. And each of those industries is still growing quickly, meaning investors haven't missed their chance to cash in.

The next step is identifying companies that are likely to benefit from those trends. That means picking stocks capable of generating market-beating returns. Of course, that's easier said than done -- but I typically invest in businesses that have a history of strong sales growth, especially those with a solid competitive edge. In my experience, those qualities often translate into outperformance.

The Trade Desk (TTD 0.70%) and DigitalOcean (DOCN 0.06%) are two stocks that check those boxes, and both look like savvy long-term investments. Here's why.

Businessman reviewing a paper document while looking at his computer.

Image source: Getty Images.

1. The Trade Desk: Programmatic digital advertising

Marketers have traditionally purchased ad space manually, engaging in time-consuming negotiations with publishers. But that approach is both costly and inefficient because marketers have a limited ability to target content and it's impossible to optimize campaigns until they are complete.

Programmatic technology (like The Trade Desk's platform) solves those problems by automating the process with real-time bidding. That means marketers can make data-driven decisions on a case-by-case basis, only paying for ad impressions that reach the desired audience. The Trade Desk's platform also leans on artificial intelligence to help clients optimize ad campaigns, surfacing predictive insights to boost conversion rates.

Notably, The Trade Desk is the leading independent (i.e. not affiliated with content) buy-side platform, and that scale gives the company an edge. Each ad powered by its technology generates valuable data, allowing the company to correlate viewer demographics with engagement. That makes its AI engine more effective over time, creating a flywheel that has already translated into strong customer retention.

In fact, The Trade Desk has kept its retention rate above 95% for the last seven consecutive years. Not surprisingly, its financial performance has been impressive. Over the past year, revenue rose 53% to $1.1 billion, powered by solid growth across all verticals, especially connected TV advertising. And free cash flow grew even more quickly, surging 139% to $317 million.

Looking ahead, The Trade Desk has plenty of room to run. Programmatic ad spend is set to reach $155 billion in 2021 -- up 20% from the prior year -- but that figure comprises just 32% of digital ad spend, and only 20% of total global ad spend. But The Trade Desk believes all media will eventually be transacted programmatically, putting the company in front of a massive and quickly growing market opportunity. That's why this stock looks like a smart long-term investment.

2. DigitalOcean: Cloud computing

DigitalOcean is a cloud computing company. It provides a range of infrastructure and platform services, including compute, storage, and tools for application development. Compared to larger cloud vendors like Microsoft, DigitalOcean differentiates itself by tailoring its services to the needs of individual developers and small- and medium-sized businesses (SMBs).

Specifically, its platform is designed to be simple, allowing customers to provision cloud services in a matter of minutes, without any formal training. The company also provides an extensive library of tutorials, and it offers 24/7 technical support to every customer. That value proposition has been a powerful growth driver.

Over the past year, the average customer spent 16% more, and DigitalOcean grew its customer base 7% to 598,000. That compounding effect drove revenue up 32% to $396.4 million. And the company generated $11.4 million in free cash flow over the last 12 months, meaning its business is pulling in enough money to pay the bills.

Going forward, DigitalOcean is well-positioned to maintain that momentum. Management puts its market opportunity at $116 billion. But the number of potential customers is growing quickly. For instance, 14 million new businesses are started each year, and the number of developers is expected to reach 45 million by 2030, up 137% from 2019. Those tailwinds should be a powerful growth driver for DigitalOcean, and shareholders should benefit, too.