If you want to build life-changing wealth, the stock market can be a great place to realize that dream. Since 1957, the S&P 500 has produced an annualized return of roughly 10.4% (including dividends). Assuming that trend continues, you could buy an exchange-traded fund that tracks the index, and your money would double roughly once every seven years. That's pretty good.

If you're willing to do some extra work, your portfolio could actually outperform the broader market. Your best chance of doing that involves thinking long-term on the stocks you choose. Don't buy a stock based on fleeting tailwinds. Instead, aim to invest in high-quality companies -- the kind of companies you would want to own forever -- and hold onto them long enough for their performance to compound your returns.

Here are two stock ideas with this investment philosophy in mind to get you started.

Group of investors analyzing various financial charts.

Image source: Getty Images.

1. MercadoLibre

MercadoLibre (MELI -0.87%) is the largest e-commerce marketplace in Latin America, and its fintech platform, Mercado Pago, is the leading provider of digital financial services for that market. In other words, this company operates in two high-growth industries, and its scale eclipses that of every rival. In fact, the MercadoLibre marketplace sees roughly 667 million visits each month. That's nearly four times the number of visits received by the next closest competitor -- which happens to be Amazon.

To reinforce that advantage, MercadoLibre has built an ecosystem around its marketplace, providing merchants with software and services that simplify commerce. For instance, sellers can access financing through Mercado Credito, ad tech tools through MercadoLibre Publicidad, and logistics support through Mercado Envios. Mercado Pago also facilitates transactions both on and off the MercadoLibre marketplace, in both online and offline locations, democratizing financial services in a region characterized by low bank account and debit card penetration.

Not surprisingly, this expansive ecosystem has made MercadoLibre popular with both buyers and sellers. Through the first half of 2021, the company had 98 million active users, up 50% from the prior year, and revenue surged 101% to $3.1 billion.

More importantly, MercadoLibre has delivered impressive financial results on a consistent basis, growing both its top and bottom lines at a steady clip.

Metric

Q2 2018 (TTM)

Q2 2021 (TTM)

CAGR

Revenue

$1.3 billion

$5.5 billion

62%

Free cash flow

$62.8 million

$182.4 million

43%

Source: YCharts. TTM = trailing-12-months. CAGR = compound annual growth rate.

Looking ahead, MercadoLibre should benefit from continued digitization in Latin America. Currently, only 57% of the population has internet access, and e-commerce accounted for just 5.6% of total retail sales in 2020, according to eMarketer. But those figures should trend upwards in the coming years. In fact, MercadoLibre's three primary geographies -- Argentina, Brazil, and Mexico -- rank among the five fastest-growing countries in the world in terms of e-commerce sales.

That's why I plan to hold this growth stock forever.

2. The Trade Desk

Traditionally, ad buyers and publishers have engaged in manual negotiations to set prices for digital ad space. This process is time-consuming and costly, and it limits the advertiser's ability to target content since data can only be collected after the campaign is over.

The Trade Desk (TTD -0.75%) solves these inefficiencies. Its programmatic platform automates the ad buying process through real-time bidding, meaning marketers can choose when and where their ads are displayed. Moreover, The Trade Desk uses bid factor technology to value ad impressions, allowing clients to create billions of targeting parameters with just a few clicks. This differentiates the company from every other buy-side platform.

Not surprisingly, The Trade Desk has achieved significant scale. Approximately 875 clients use its platform to buy inventory from 82 ad exchanges and supply-side partners. In turn, The Trade Desk captures data from over 600 billion impressions each day, which powers the predictive insights surfaced by its artificial intelligence engine, allowing clients to optimize campaign performance in real-time.

Looking back, The Trade Desk has delivered an impressive financial performance in recent years -- and unlike many high-growth tech companies, it's profitable on a GAAP basis.

Metric

Q2 2018 (TTM)

Q2 2021 (TTM)

CAGR

Revenue

$380.1 million

$1.0 billion

40%

Free cash flow

$41.7 million

$280.1 million

89%

Source: YCharts. TTM = trailing-12-months. CAGR = compound annual growth rate.

Looking ahead, The Trade Desk has plenty of room to grow its business. Despite the clear benefits of programmatic ad buying, this technology accounted for just $129 billion (20%) of total global ad spend in 2020. But the industry is moving away from traditional solutions, and The Trade Desk believes all media will be transacted programmatically in the future.

That's why I plan to hold this stock forever.