The stock market has stabilized a bit in recent weeks, but lots of high-quality stocks are still hanging out in Wall Street's bargain bin. Smart investors can set up fantastic long-term positions by sifting the wheat from the chaff in that pile.

Today, I'm particularly interested in next-generation database expert MongoDB (MDB -2.41%) and media-streaming technology developer Roku (ROKU -3.05%). Both stocks have fallen more than 65% year to date, but their long-term business prospects are as bright as ever. Picking up these top-shelf tech stocks on the cheap right now could make you some serious money over the next five to 10 years.

MongoDB: Down 66% in 2022

The database specialist isn't exactly cheap, even after this year's dramatic price drop. Shares are trading for 11.8 times trailing sales and 3,300 times forward earnings estimates. These ratios are enough to send traditional value investors running for the sidelines.

However, MongoDB is a bargain on a relative basis. That beefy sales-to-earnings ratio sits far below the three-year average of 27.5. Analysts are expecting positive earnings in the next fiscal year, and that's a first for MongoDB.

MDB PS Ratio Chart

MDB PS Ratio data by YCharts

The business is headed in the right direction, even in today's unpredictable market. Second-quarter sales rose 53% year over year and gross profits increased by 56% over the same period. The bottom line is printed in red ink only because MongoDB's sales and marketing budget is growing at an even faster 66% clip.

MongoDB is executing a classic high-growth business plan here. Developers are hungry for fast, stable, and powerful database solutions that can manage huge streams of unstructured data. MongoDB delivers that in such a way that a customer can take advantage of these qualities with a fairly small staff of database administrators. These tools are a perfect fit for many modern information technology tasks, such as managing messy real-world data collected by sensors in an Internet of Things device, or direct input from app users.

In other words, MongoDB is pushing the growth pedal to the metal in this promising market moment. This is the time to expand the user base and target market share gains as quickly as possible. Profits and cash flows will come later, when it makes sense to slow down that torrential marketing effort.

So MongoDB's stock is a bargain from that angle, with the caveat that the road ahead will remain bumpy for several years. That's just the nature of life in the fast lane. Maturity and solid profits have to wait, and growth-oriented investors should see robust long-term returns from today's modest starting price.

Roku: Down 75% in 2022

Value investors should be more comfortable with Roku. This stock trades at just 2.6 times trailing sales, and the company boasts average annual revenue growth of 55%.

Recent quarterly reports have been a bit rough, showing sales growth of just 18% in Q2. But just like MongoDB, Roku is putting its back into returning to the tremendous revenue gains of the last few years. This company's sales and marketing expenses doubled in the second quarter, while research and development costs rose by 74%.

Unlike MongoDB, Roku already has a history of generating positive earnings and cash flows. The current dip below the break-even point is the result of advertisers holding back their marketing budgets in this time of inflation fears and tight consumer budgets. The lull should end when advertisers revive those restricted marketing efforts. Eventually, it will once again make sense to hunt for sales growth in a healthier economy.

Meanwhile, Roku's history of solid bottom-line results has created a rock-solid balance sheet, with $2 billion of cash equivalents and less than $0.1 billion of long-term debt. The company can weather a long-lasting market storm if necessary. On the other side of these rough waters, Roku will benefit from the unstoppable global growth of media-streaming services.

And nearly all of the company's fortunes so far have come from North America, with minuscule contributions from Latin America and Western Europe. Global expansion should be an important theme for Roku in the next few years.

All things considered, Roku's stock should be worth several times the skimpy price-to-sales ratio you see today. The shares look like a no-brainer buy right now.