The technology sector is struggling right now as investors try to determine what's happening with the economy and whether or not a recession is on the horizon. 

And while there are certainly macroeconomic headwinds that shouldn't be ignored, writing off all tech stocks could be a huge mistake when the market eventually rebounds (because it always does).

If you have $3,000 to invest and are looking for companies that could be great long-term winners, consider what Block (SQ -0.50%) and The Trade Desk (TTD -0.17%) are doing.

A person looking at computer.

Image source: Getty Images.

Block's payment platform is still growing

You may know Block better by its former name, Square, which initially gained investors' attention for its payment terminals and payment processing systems for businesses of all sizes.

Now, the Block company includes many businesses including Square, Cash App, the streaming music service Tidal, and the blockchain company TBD. 

The company's bread and butter is its Cash App, which allows people to pay each other and businesses. In the third quarter, Cash App generated $2.8 billion in sales -- up 12% year over year. And when you exclude Bitcoin and the company's buy now pay later (BNPL) platform, Cash App revenue was $817 million -- up 41% year over year. 

Cash App's growth helped push Block's total sales up 17% in the quarter to $4.5 billion. Additionally, Block's gross profit jumped 38% to $1.5 billion. 

Like other tech stocks over the past year, Block's stock is hurting right now and is down 64% over the past 12 months.

But that drop is also creating a better buying opportunity for investors. The company's shares are trading at 2.1 times the company's sales, compared to a price-to-sales (P/S) ratio of about 5.7 this time last year. 

The Trade Desk's ad opportunity 

The Trade Desk may seem like an odd choice right now, especially as the advertising market has begun to slow down for a handful of companies recently.

The Trade Desk's advertising platform -- which helps companies buy and place ads across the internet, television platforms, and mobile apps -- is growing fast despite macroeconomic headwinds.  

And one unique opportunity The Trade Desk has in the ad space is that it's helped create a unique identifier -- called Unified ID 2.0 -- that is helping companies move away from online cookies (trackers), while still being able to target ads that don't compromise user privacy. Unified ID 2.0 has already been adopted by a host of companies, including one of the world's largest advertisers, Procter & Gamble

In the third quarter (reported on Sept. 30), the company's sales rose 31% to $395 million and non-GAAP (adjusted) earnings increased 44% to $0.26 per share. 

And there's plenty of more room to grow considering that U.S. digital ad spending will become a $385.4 billion market by 2026, up from $248.7 billion in 2022, according to eMarketer. 

In addition to its strong financial position, The Trade Desk has had an impressive customer retention rate of above 95% -- for eight consecutive years.

Investors looking for a good deal right now will be happy to know that The Trade Desk's stock is currently trading at a P/S ratio of about 16, which is significantly cheaper than its P/S ratio of about 40 this time last year.  

Invest for years, not months

There's likely to be continued volatility in the stock market, which will probably affect Block's and The Trade Desk's share prices in the short term.

But investors should plan now for the tech sector's rebound and remember that buying and holding on to stocks for five years (or longer) is still a great way to build wealth.