If you'd invested $5,000 in an S&P 500 index fund 10 years ago, your investment would be worth around $12,500 today. That's a rock-solid return, but investors could have fared even better if they had simply bought and held a few individual stocks.

For example, a $5,000 investment in Amazon (AMZN 3.48%) would have grown over the past decade to around $44,000, while the same investment in Google (whose parent company is now called Alphabet) would be worth nearly $27,000 today. Not every stock will be the next Amazon or Alphabet, but some lucrative long-term buying opportunities have emerged in the growing cloud, semiconductor, and ad-tech markets as the grueling bear market drags on. 

A person reviews financial reports in front of a trading screen.

Image source: Getty Images.

1. The cloud play: Microsoft

Microsoft (MSFT 2.56%) owns Azure, the second-largest cloud infrastructure platform in the world after Amazon Web Services (AWS). Microsoft enjoys two advantages against Amazon in the cloud market: Azure is growing faster than AWS, and it's a popular choice for companies (particularly retailers) that directly compete against Amazon's other businesses.

Microsoft also represents a more straightforward play on the growing cloud market because it isn't burdened by a lower-margin retail business like Amazon. Its cloud services, which generated nearly half its revenue last quarter, also directly support its desktop software, mobile apps, Windows operating system, and Xbox gaming business.

Microsoft's expansion of its cloud ecosystem, which was largely executed under CEO Satya Nadella, transformed it from a dusty old tech stock into a high-growth company again. Analysts expect its annual revenue to grow at a compound annual growth rate (CAGR) of 13% between fiscal 2022 (which ended in June) and fiscal 2025, and for its earnings per share (EPS) to grow at a CAGR of 13%. Those solid growth rates, which should be supported by its ongoing dominance of the enterprise software market, make it a great long-term investment.

2. The chip play: ASML Holding

For investors who want exposure to the semiconductor sector but are intimidated by the cutthroat competition between individual chipmakers, ASML Holding (ASML 2.29%) is an ideal investment. The Dutch company is the largest supplier of photolithography systems, which are used to etch circuit patterns onto silicon wafers, and the only producer of EUV (extreme ultraviolet) systems, which cost $200 million each and are required to manufacture the world's smallest and densest chips.

ASML's top customers include the three most advanced chip foundries in the world: Taiwan Semiconductor Manufacturing, Samsung, and Intel. Most fabless chipmakers -- such as Advanced Micro Devices, Nvidia, and Qualcomm -- rely on those foundries to manufacture their top-tier chips. In other words, it would be impossible to produce new cutting-edge chips without ASML's machines. 

ASML's monopolization of this market makes it a wonderful long-term investment, even if the chip sector struggles with near-term cyclical headwinds. Between 2021 and 2024, analysts expect its revenue and EPS to grow at a CAGR of 15% and 17%, respectively. That steady growth makes it a top investment in the secular growth of the semiconductor market.

3. The ad-tech play: Magnite

Magnite (MGNI 3.64%) is the world's largest independent sell-side platform (SSP) for digital ads. SSPs, which shouldn't be confused with demand-side platforms like The Trade Desk, help publishers manage and sell their own ad inventories.

Magnite emerged from the merger of two other ad-tech companies, The Rubicon Project and Telaria, back in 2020. It subsequently acquired several additional companies to increase its exposure to the CTV (connected TV) market. 

Magnite's acquisitions obfuscated its organic growth rates, and macro headwinds throttled the growth of its desktop, mobile, and CTV ads over the past year. However, Magnite expects to overcome those near-term challenges and eventually generate more than 25% annual revenue growth organically over the long term as its CTV segment expands. It also expects its adjusted EBITDA (earnings before interest, taxes, depreciation, and amortization) margin to stay between 35%-40%.

Analysts expect its annual revenue and adjusted EBITDA to both grow at a CAGR of 19% from 2021 to 2024, and for its adjusted EBITDA margin to stay at around 36% through the final year. If those more conservative estimates are accurate, Magnite's stock remains deeply undervalued at less than two times this year's sales and five times its adjusted EBITDA.