The stock market should seem attractive to you, because it's one of the best ways to build wealth and financial security for yourself over the long run. Averaging about 10% annually over long periods, it can turn a single $10,000 investment into almost $175,000 in 30 years. (So imagine what can happen if you invest more over time!) You have to be smart about it, though. Ideally, you'll keep learning how to invest in stocks more profitably for the rest of your investing life.

Learning how to invest in stocks effectively isn't hard, but many people never take the time to do it. Thus, they commit many classic blunders. Below are a few things that can cause you to get poor results when investing. Avoid these pitfalls and you'll likely boost your portfolio's performance.

The classic maxim offered to those who want to learn how to invest in stocks is "Buy low, sell high." Yet despite that, many people do the opposite. They buy into stocks without a grasp of whether the stock is undervalued or overvalued. And if it suddenly heads south, they sell in a panic, locking in a loss instead of the hoped-for gain. Succumbing to fear and greed is a big no-no when investing. Choose stocks carefully after studying them, and aim to hang on for the long haul, as long as the underlying companies remain healthy, growing, and with sustainable competitive advantages. Expect ups and downs for your stocks and the overall market, and don't freak out when they occur.

Frequent trading
Buying and selling stocks frequently means that you're likely forking over a lot in trading commissions. Even a low $7 fee will add up over time if you trade 20 times a month. That's 240 trades per year -- totaling $1,680. Ouch. Aim to invest with more conviction and less trading.

Buying into companies and industries that you don't understand is not how to invest in stocks profitably. If a company is losing its edge due to a new, emerging technology or a disruptive competitor, you may not realize it and may not get out in time. Alternatively, you may find a compelling industry, but then invest in the least promising company in it. The more you know, the better you should do. It can help to learn how to make sense of financial statements, too, as just a few numbers in them can sometimes reveal a lot.

Another pitfall many people encounter when learning how to invest in stocks is to take your eye off the ball. You might invest in a handful of promising stocks, but then fail to keep up with the companies and their progress. Make sure to compare their performance to an appropriate benchmark, such as the S&P 500. If a stock (or a mutual fund) has averaged 11% annually for you, but the S&P 500 has averaged 14% over that same period, you're not doing as well as you might think. If you've averaged only a 3% gain when the overall market lost 15%, you actually did well. Part of the secret to succeeding at investing is to keep up with your holdings and keep track of how well you're doing.

Remember that if you're having trouble beating the overall market (or you anticipate that you will), you can simply invest in the market -- all of it -- via a low-cost broad-market index fund. There are index funds and exchange-traded funds such as the Vanguard 500 Index Fund (NASDAQMUTFUND:VFINX) or the SPDR S&P 500 ETF (NYSEMKT:SPY) that track the S&P 500, while the U.S.-based Vanguard Total Stock Market Fund (NASDAQMUTFUND:VTSMX) and the globally focused Vanguard Total World Stock Market ETF (NYSEMKT:VT) deliver even broader holdings. These kinds of investments offer low fees (often a small fraction of a percent annually) -- and these particular ones have especially low fees. They all permit you to immediately be well diversified, invested in hundreds or thousands of companies. Over long periods, broad index funds such as these have actually outperformed most managed stock funds, so it can make a lot of sense to consider them.

Learning how to invest in stocks effectively is critical if you want to build a more secure financial future. It's not rocket science but it does require discipline. If you can avoid falling prey to these common pitfalls, you'll have come a long way toward achieving investment success.

Longtime Fool contributor Selena Maranjianwhom you can follow on Twitterhas no position in any stocks mentioned, though she is invested in some index funds. The Motley Fool has no position in any of the stocks mentioned. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.