You've probably noticed how volatile the technology sector is right now, and it could be a little while longer before things stabilize.

The tech-heavy Nasdaq Composite is down 20% over the past 12 months, and that means there are great, beaten-down tech stocks out there that have the potential to bring investors significant gains in the coming years. 

If you've got $5,000 to invest right now -- and an investment horizon that you measure in years and not months -- splitting that cash between The Trade Desk (TTD -4.34%) and Roku (ROKU -3.05%) could be a smart move. Here's why. 

A person looking at a computer.

Image source: Getty Images.

1. The Trade Desk 

Advertising companies haven't exactly been having a fantastic time as inflation has skyrocketed and a potential recession looms.

But while the ad industry, in general, is experiencing a temporary slowdown right now, The Trade Desk is poised to benefit when it rebounds. And the ad market always does

The Trade Desk's platform allows companies to buy ads across the Internet and connected devices, and it's helping the ad industry transition away from online trackers called cookies. 

The Trade Desk's Unified ID 2.0 is a replacement for online cookies that allows companies to still offer advertisers the ability to target ads while offering more privacy for online users. 

Unified ID 2.0 is already being used by fuboTV, The Washington Post, Amazon Web Services, and many more companies. 

And while the ad market is feeling a pinch right now, The Trade Desk's sales are still growing at a healthy clip. Third-quarter sales rose 31% to $395 million, and the company expects at least 24% growth in the fourth quarter to $490 million. 

Over the short term, The Trade Desk's growth could be a bit choppy as some companies try to gauge how much they should spend on advertising, but any pullback will be temporary. 

Digital advertising may be in transition right now, but it's still an extremely large opportunity. Research from Insider Intelligence estimates the digital ad market will reach a size of $696 billion in 2024, up from $567 billion last year. 

Additionally, while The Trade Desk's shares aren't cheap right now, they are the least expensive they've been in nearly three years with the company's price-to-sales ratio of 16.5 as of this writing. 

2. Roku 

Some investors have dismissed Roku's stock, because they view it as purely a pandemic play that peaked when people were stuck at home, hungry for entertainment.

But that's a bit short-sighted, and the company's third-quarter results prove it. Roku's active accounts increased 16% year over year to 65.4 million, and the number of streaming hours on the platform jumped 21% to 21.9 billion hours. Those figures further increased to over 70 million and 23.9 billion, respectively, by the start of the new year.  

Not only are active accounts and streaming hours increasing, but the company's average revenue per user (ARPU) also ticked 10% higher in the third quarter to $44.25. 

That proves Roku isn't just a pandemic play, but what about the future of the company in the coming years?

Roku should benefit from the same digital advertising market that The Trade Desk is tapping into. As the leading video streaming platform company in the U.S., Canada, and Mexico, Roku can benefit from the rise of streaming, no matter which services are popular in those countries. 

Sales were up by 12% in the quarter to $761.4 million, which shows that even during difficult times, Roku can still grow its business. 

And with Roku's stock trading at a price-to-sales ratio of just 2.3 right now, that is a bargain valuation compared to the past few years.

Remember that these are long-term bets

It can be tempting to expect tech stocks to rise quickly, but you'll need to be patient with them right now as investors assess the broader economic picture. 

But if you've got a multiyear investing timeline, these two tech stocks look like great buys right now that could prove to be smart investments just a few years down the road.