Just about anyone who had money in the market is saying, "Thank you, 2016!"

The vast majority of investors -- 77% -- made money this year, according to data shared first with CNNMoney by Openfolio, an app that lets people see how their returns stack up to other investors'. Women outperformed men for the third year in a row, Openfolio found.

It's a big turnaround from last year when most people, men and women alike, LOST money.

"Rising investor optimism and the stock market reaching all-time highs is great news to end the year on," says Scott Wren, senior global equity strategist at Wells Fargo Investment Institute.

The average investor made just over 5% in 2016, according to Openfolio.

Related: Dow finishes a wild year with a big gain

That may not sound like a lot given that the Dow is up a whopping 13.4%, its biggest gain since 2013, but most investors don't put all their money into U.S. stocks. They diversify by investing in bonds, Europe, Japan, emerging markets and commodities like gold and oil. In fact, Russia turned out to be one of the top-performing stock markets of 2016.

"We're telling investors to stick to what you've got. Stay diversified. This is NOT the environment to take more risk in," says investment strategist Kate Warne of Edward Jones.

Related: Russia is a top stock market of 2016

Stocks and funds that soared

Anyone disappointed with only a 5% gain should take a look at the savings in their bank account. Savers are still barely earning above 0% interest. Putting money in the market was the more profitable move.

Openfolio found that people who made a lot of money in the markets this year invested in hot tech stocks like Apple (AAPL), Facebook (FB) and Tesla (TSLA) and financial stocks, which made a huge upswing after Donald Trump won the election.

Apple is by far the most popular stock held by average investors. It is up more than 10% this year on optimism about better iPhone sales (especially after the Samsung Galaxy Note 7 disaster) and new products in the works.

Other popular stocks this year were Facebook (also up 10%), Bank of America (BAC) (up 31%), Goldman Sachs (GS)(up 33%), Advanced Micro Devices (AMD)(up 300%), Amazon (AMZN) (up 11%) and Netflix (NFLX) (up 8%).

Related: 5 stocks to buy in 2017

What's next for 2017?

In addition to individual stocks, investors who are ending the year smiling had money in low-cost index funds (Warren Buffett's recommended investment vehicle for regular folks) such as Vanguard FTSE Emerging Markets ETF (VWO) (up 9.3%) and Vanguard Total Stock Market ETF (VTI) (up 10.6%).

People who lost money tended to be holding some popular stocks that tanked this year, including Twitter (TWTR) (down 30%), GoPro (GPRO) (down 52%), FitBit (FIT) (down 75%) and Under Armour (UA) (down 30%).

So where's the market headed for 2017? The Wall Street "experts" still predict it will go higher, though for a smaller gain than 2016.

"The market may have gotten ahead of itself. It's too soon to know what specific policies president-elect Trump will pursue and which ones he will be able to implement," says Seth Masters, chief investment officer at AB Bernstein.

The general consensus is to buckle up and expect another wild ride. But remember: The U.S. stock market has always made money for investors who stay in for the long haul.