It helps to have a glass-half-full attitude when investing in stocks, especially when historical trends back this optimism. Equities have had it rough over the past 12 months, but history tells us U.S. stocks have a track record of eventually recouping their losses and delivering solid returns, especially to those investors who hold their shares through thick and thin. 

Before the next bull market gets underway, it would be a good idea to pick up shares of companies that are down now, but that still have what it takes to be long-term winners.

Let's look at two examples: Shopify (SHOP -0.50%) and Roku (ROKU 0.57%). These stocks are among the largest holdings in Cathie Wood's Ark Invest exchange-traded fund, and with good reason.

1. Shopify

Shopify has delivered market-crushing returns since its IPO in 2015. But its financial results have been up and down since the coronavirus pandemic started in 2020. Shoppers migrated to online retailers en masse in the early days of the crisis, boosting Shopify's business. That tailwind is now much diminished, and the company's more recent results appear uninspiring compared to those early-pandemic days. Where does that leave the company?

In my view, still in a great place.

First, Shopify remains a leader in e-commerce, with its platform responsible for roughly 10% of the U.S. market's gross merchandise volume. Second, the e-commerce industry represents a massive long-term opportunity. Online commerce is often more convenient for shoppers. Nothing beats making purchases from the comfort of one's home.

Meanwhile, it is more efficient for merchants. They can reach broader audiences while reducing expenses and costs related to running brick-and-mortar stores.

Third, Shopify's business is strong. The company offers merchants everything they need to build an online store and attract customers, from various payment options to inventory to the ability to reach clients on popular social media websites such as YouTube, Twitter, and Facebook.

Another critical strength of Shopify's business is that leaving it involves high switching costs. Merchants make investments in both money and time when they build and customize their online storefronts on its platform. It's harder to justify the effort and expense of jumping ship to a new platform, especially after a business has managed to attract customers. That's why many of Shopify's merchants are likely to stay put.

Shopify will also continue adding new features. The company is still building its fulfillment network, for instance.

Although it has faced challenges of late, Shopify's attractive long-term prospects still make it a solid stock to buy, something investors should consider doing before the next bull market. Though they are still down by more than 70% from their peak, Shopify's shares are up by 38% so far this year. 

2. Roku 

Roku's shares dropped like a rock last year as the company and its peers that rely on advertising to make a buck faced a substantially more challenging landscape. The streaming video specialist's revenue growth rate declined, and it reported a massive net loss in 2022 as its expenses soared, partly due to inflation and supply chain issues.

ROKU Revenue (Quarterly YoY Growth) Chart

ROKU Revenue (Quarterly YoY Growth) data by YCharts.

But Roku maintained its momentum on a couple of key metrics.

Roku ended 2022 with 70 million active accounts, a 16% year-over-year increase. Also, streaming hours on its platform jumped by 23% year over year to 23.9 billion. These points matter a great deal. While the current pullback in ad spending is temporary and due to macroeconomic conditions, the streaming video industry is on a long-term growth path that won't be substantially affected by economic cycles.

And by strengthening its ecosystem with more viewers who are spending more time watching the content it delivers, Roku is ensuring that it will continue to profit from the ongoing switch to streaming once these economic challenges subside.

Just how massive is the worldwide opportunity in streaming? Consider that it made up just 34.3% of total television viewing time in February in the U.S., where streaming is more penetrated than in most other places.

Several platforms are battling for supremacy in the industry, and Netflix remains the leader. But Roku's platform hosts a range of alternatives. As long as viewers remain plugged into its ecosystem, it doesn't really matter whether Netflix or some other service rises to the top. Roku will benefit for a long time as advertising moves from traditional linear television to streaming, a process that is ongoing but arguably still has much farther to go before it plateaus.

However, the company's stock remains down by 47% over the past 12 months. That means it's a great time to initiate a position in Roku before Wall Street enters its next bull market.