The Nasdaq-100 index is often used as a barometer for the technology sector's performance. It has declined about 31% this year and is approaching its 52-week low point, potentially triggering even more pessimism among investors.

But optimists will tell you there's one thing we know for sure: Throughout history, the stock market has always broadly recovered to new highs, given enough time. For that reason, this isn't a time to panic. Instead, investors should be on the hunt for quality opportunities they can hold for the long run.

Stock selection, of course, makes all the difference. Some companies have declined in value steeply from their pandemic-era highs set in 2020 and 2021, but that doesn't necessarily mean they'll reclaim those levels when the economic environment evolves. With that in mind, here's one stock to buy now and one to avoid.

The stock to buy: Atlassian

Atlassian (TEAM -9.46%) is a developer of software tools designed to help organizations collaborate. And it's in the middle of a major transition to deliver its platforms in the cloud, which is a key reason investors should own the stock for the long run. The cloud is a rapidly expanding technology that helps companies shift their networks online, eliminating the need for clunky on-premise software that continuously needs updating.

Atlassian sees that its customers using cloud-based versions of its products grew their businesses 30% more quickly and spent 30% more with the company each year as a result. That helped Atlassian's cloud-based revenue rapidly increase to represent over half of the company's $759 million in total revenue during the recent fourth quarter of fiscal 2022 (ended June 30).

Over 242,600 businesses use Atlassian's platforms. Its flagship Jira tool was intended to help development teams deliver their software projects, but it is now used by workers in several roles within organizations to collaborate on tasks. But Atlassian feels it has only scratched the surface of its addressable market, with a potential 2.2 million business customers up for grabs worldwide.

The company generated $2.8 billion in revenue for the fiscal 2022 full year, but it's eagerly working toward $10 billion annually. While it hasn't set a timeframe for reaching that target, it will almost certainly be driven by its cloud product sales, which it expects could grow by 50% per year in fiscal 2023 and fiscal 2024. Since 99% of new Atlassian customers are signing on to the cloud immediately, not much stands in the way of hitting the mark in the long term.

Atlassian's stock price is down 55% from its all-time high, but it's one example of a company with a bright future regardless of what the broader market is doing. For that reason, it might be time to buy.

The stock to sell: Peloton

Peloton Interactive (PTON 4.62%) was one of the hottest stocks on the market in 2020 and 2021, when the pandemic was at its worst. Why? Gyms were closed, people lived under social restrictions, and office-based employees mostly worked from home. Therefore, Peloton's range of at-home exercise equipment soared in popularity. Its flagship Bike is fitted with a digital screen that can be used to watch Peloton's virtual fitness classes and served as an acceptable outlet for exercise enthusiasts, given the circumstances.

But the company has suffered a remarkable fall from grace. To put it in perspective, Peloton stock reached an all-time high of $162.72 per share in December 2020 but now trades at just $8.51 -- a 94% collapse. Demand for its products declined, as has engagement, with the number of average monthly workouts by Peloton subscribers dropping to 14.8 in the recent fourth quarter of fiscal 2022 (ended June 30). The metric is 43% lower than its pandemic-era high point of 26.

The company's revenue is now in a concerning downtrend. After peaking at $4 billion in fiscal 2021, it fell to $3.5 billion in fiscal 2022 -- and analysts predict it will drop even further to just $3 billion in fiscal 2023. That's despite a freshly inked partnership with e-commerce giant Amazon, which will allow Peloton to sell its products on Amazon.com, marking its first time to venture outside its own sales channels.

But the company continues to press ahead with innovations like its new row machine, designed to expand upon the success of its Bike by adding additional workouts to Peloton enthusiasts' repertoire. However, at $3,195, it's rather pricey, which could hurt demand since consumers are tightening their belts in this difficult economy.

Of greatest concern are Peloton's net losses. The company was in the red to the tune of $2.8 billion in fiscal 2022, and it's now rapidly cutting costs to stem the bleeding. The simple fact is that Peloton appears destined to be a much smaller business going forward than it has been over the last two years, and investors should instead be focusing on companies that are growing.