What you should know before you invest in stocks

Make your money count
Make your money count   

Most financial experts agree that the best time to start investing in stocks is when you're young and have time to wait out the downturns and take full advantage of compounding. But it's not easy to know where to start.

That might explain why just 26 percent of Americans under age 30 are now investing in the stock market, according to a recent survey by Bankrate.com. Compare that with 58 percent of people between ages 50 and 64 who invest.

Sure, the fact that boomers are older may explain some of the difference. But age isn't the only factor. In a recent study, millennials said that a lack of financial knowledge makes them less confident about investing. And a lack of information was the number two reason respondents of every age in the Bankrate survey gave for avoiding the market (the other was a lack of money).

Here's what you should know before you invest so you can make the most of your money.

Read MoreMillennial money habits worth breaking

Before you even open an investment account, make sure you've paid off your credit card debt and that you have emergency money set aside in a savings account in case you get hit with unexpected expenses or a job loss (aim for enough to cover about three to six months' worth of expenses).

You also want to make sure you're taking full advantage of the benefits of tax-advantaged retirement accounts. Advisors recommend maxing out your employer-sponsored plan or individual retirement account before opening a regular investment account. "The first place to consider putting money is an employer plan because those often have matching funds and you want to get all of those you can," said certified financial planner Dan Moisand of Moisand Fitzgerald Tamayo in Melbourne, Florida.

For 2015, you can contribute up to $18,000 in your 401(k). If you're not able to meet the maximum, aim to contribute at least enough to take full advantage of any employer match. That's free money!

Read MoreHow to get lucky with your savings

Don't have access to a 401(k)? There are other options. You can contribute up to $5,500 this year into a Roth IRA or a regular IRA.

A Roth IRA lets you grow your money tax-free, but you do pay taxes on contributions. With a regular IRA you'll be taxed when you start taking money out, but you won't pay taxes in the meantime on annual gains.

If you're fortunate enough to have exercised those options and still have some cash left over, you can open a regular investment account. But there are a few things to keep in mind.

Read MoreJob hunting tips for millennials

millennial saving money retirement
Jamie Grill | Getty Images

First, look for ways to keep costs down. You can start with low-cost brokers like Schwab, Vanguard, TD Ameritrade or Fidelity. Or try an automated investment service like Betterment or Wealthfront. The low-cost "robo-advisors" offer fund suggestions based on your risk level, goals and timeline.

Low-fee passive funds can help you keep costs low and diversify. A passive mutual fund or an exchange-traded fund (or ETF) gives you access to a broad range of stocks (or bonds or other assets). They mirror indexes like the Standard & Poor's 500 and have low expense ratios. (You can look up a fund's expense ratio and historical returns through Morningstar.com or your brokerage firm.)

Don't forget to diversify—both within your funds and within your overall portfolio. The markets go up and down, but over time the stock market has provided an average annual return of 6 to 8 percent.

And as a millennial, time is one your side. Even if you invest $50 or $100 a month, you have decades to take advantage of compounding and grow your money. If you set aside money to invest and diversify your investments, you can set yourself up now to retire well later.