The S&P 500 has gained about 1.3% so far this year, and investors searching for bigger gains are having to contend with a very volatile market. But there are a few companies putting up impressive returns over the past few months. Two of them are Nvidia (NVDA 3.77%) and The Trade Desk (TTD 3.13%)

These two companies are easily outpacing the broader market's returns year to date, and, just as importantly, both companies have strong businesses that could continue to do well in the years to come. Here's why the semiconductor giant and digital ad company should be on your buy list. 

A person looking at a phone.

Image source: GETTY IMAGES.

Nvidia -- up 65% year to date

Nvidia graphics processing units (GPUs) have long been a staple for high-end graphics in the gaming sector, and over the past years they've been used more and more for data centers and artificial intelligence. 

And it's in those two markets that Nvidia has significant opportunities. Large tech companies utilize Nvidia's GPUs for many of their cloud computing needs, and this has helped Nvidia's data center business to grow steadily. Data center sales accounted for 67% of the company's total revenue in the fourth quarter, and sales increased 11% in quarter to $3.6 billion -- and are up 90% from just two years ago.  

That growth is impressive enough on its own, but Nvidia is also tapping into another huge trend: artificial intelligence. Most recently, Microsoft is using thousands of Nvidia processors to help train ChatGPT, the popular large language model that Microsoft is implementing into its software and services (including Word, Bing search, and Azure cloud computing).

The good news for Nvidia is that that no matter who takes the lead in the AI arms race, Nvidia will likely benefit as a key source of high-powered semiconductors for this space. Nvidia believes that its AI chips' total addressable market size is a staggering $300 billion. And with AI already a major focus for tech companies, Nvidia is already positioned to benefit as AI chip demand grows. 

The Trade Desk -- up 23% year to date

The Trade Desk is an online platform for buying digital advertising that get placed on internet-connected devices, such as phones and smart TVs, and the company has seen substantial growth in the digital ad market over the past year. 

In the third quarter, the company's sales increased by 24% to $491 million, which is impressive given that many companies experienced falling ad revenue over the past several quarters. Part of the company's success has come from its ability to navigate changes in the digital ad market, including the shift away from online trackers (called cookies). 

As the industry has moved away from cookies, The Trade Desk helped develop an innovative online identifier called Unified ID 2.0 (UID2) that helps protect user privacy while still allowing companies to serve targeted online ads. UID2 has already been adopted by a large and growing number of companies such as The Washington Post, fuboTV, and Amazon Web Services, proving its success.

While some investors may be wary of the digital ad market right now, they should keep in mind that this market is expected to expand quickly over the next few years, reaching an estimated global size of about $696 billion in 2024, up from $567 billion in 2022, according to research from Insider Intelligence.

Keep this in mind 

It's worth mentioning that Nvidia and The Trade Desk's recent share price gains made the stocks expensive relative to the broader market. Nvidia's shares currently trade at 55 times the company's forward earnings, and The Trade Desk has a forward P/E ratio of 48, both of which are well above the S&P 500's forward price-to-earnings ratio of 18.

That doesn't mean these stocks aren't buys, it just means that investors should know that buying them right now means paying a premium for these companies. But owning these stocks over the next five years or more could prove to be a wise bet, as Nvidia and The Trade Desk continue to tap into the vast AI and digital advertising markets.