In the midst of a bear market, many investors saw 2018 shape up to be their first losing year in a long time. For much of the past decade, all you've had to do is invest in the broader market to make a lot of money. But with the S&P 500 down as much as 20% from its recent highs, winning stocks are now much harder to come by.

Yet a few stocks managed to overcome the downward pressure and maintain sizable gains for the year. Among the best performers in 2018 were Tandem Diabetes Care (NASDAQ:TNDM), Twilio (NYSE:TWLO), and Amarin (NASDAQ:AMRN): An investor who had split $1,000 three ways and invested it in those three stocks on Jan. 1, 2018, would have nearly $7,000 now. Let's take a look at how these companies did it, and attempt to predict whether they are likely to make further gains in the coming year.

TWLO Chart

TWLO data by YCharts.

Caring for patients -- and investors

Diabetes has become a serious health threat to the global population, and companies seeking to help diabetics deal with their disease have attracted a lot of interest from investors lately. Tandem Diabetes Care in particular has a long history of selling insulin pumps that those suffering from either type 1 or type 2 diabetes can use to help manage their disease. Although there's plenty of competition in the diabetes space, Tandem has enjoyed great success recently after debuting an automated insulin delivery system that pairs with a continuous glucose monitor to ensure an appropriate flow of insulin into the body. It saves patients from having to determine their glucose levels themselves, while also preventing dangerous situations from arising due to less precise measurements.

Electronic display attached to a monitoring device.

Image source: Tandem Diabetes Care.

Tandem estimates that its market share in insulin pumps has grown to about 12%, and while it still will be attempting to draw customers away from much larger competitors in the medical device space, management and analysts are optimistic about its chances. Its stock has jumped roughly 1,300% in the past 12 months, and many see even more promise for the company as it continues to serve a growing population suffering from diabetes.

Connecting with big gains

The cloud computing space has been a big growth driver recently, and Twilio plays an important part in the industry by providing specialized communications services. Essentially, Twilio helps mobile app publishers connect with their users, a role that's become increasingly important for many businesses. With high-profile clients like Netflix, Airbnb, and Lyft, Twilio makes sure that mission-critical communications happen effectively and efficiently behind the scenes, producing a seamless service for Twilio's clients and their respective end-users.

Twilio has been experiencing amazing growth which shows no signs of slowing -- the company posted a 68% rise in revenue in its most recent quarter. With its recently rolled-out Flex cloud contact-center platform, and the acquisition of email delivery specialist SendGrid, Twilio is working hard to lock up its leadership position in cloud communications. Thousands of clients have discovered how invaluable Twilio's service is for their businesses, and shareholders have benefited too. The stock price has more than tripled over the past year.

A healthy gain

Finally, the biopharmaceutical Amarin has produced solid profits for shareholders over the past year, more than tripling from where it was near the end of 2017. The main driver for the stock's big rise came in September, when the company released positive trial results from a study of its Vascepa fish-oil pill. The study of more than 8,000 people looked at how taking Vascepa affected incidence of heart attack, stroke, and other major adverse cardiovascular events. The results were much more encouraging than many had expected, and though a number of medical experts have expressed concerns about the structure of the study, among other issues, that hasn't had much impact on Amarin's share-price gains.

The big question for Amarin is how it'll capitalize on the potential of Vascepa. Many see it as a takeover candidate, as many larger pharmaceutical companies are looking for opportunities to boost their new treatment pipelines. Yet others think the company would fare better by remaining independent. Either way, today's shareholders could end up even bigger winners.

Keep your eyes open for winners

No matter how challenging an environment the stock market faces, there will always be some companies delivering impressive share-price gains. Amarin, Twilio, and Tandem might not be able to duplicate their 2018 returns, but they do have potential for years of further success, and their stockholders should share in the benefits.

Check out the latest Tandem Diabetes CareTwilio, and Amarin earnings call transcripts.