Source: via Flickr.

Millions of Americans don't have enough saved for retirement and are making costly mistakes that ultimately reduce their quality of life and financial independence in their golden years. Fortunately, many of these mistakes are easily avoided.

Let's look at five lessons every investor needs to learn in order to avoid unnecessary costs and ensure a comfortable retirement.

1. Don't time market cycles
When the market's down, many ordinary investors panic and sell. Meanwhile, when everything looks good and the market is riding high, they move their money back in. That's a classic "sell low, buy high" approach that can be extremely costly in the long term.

Source: Wikimedia Commons.

While there have been major speed bumps along the way, the stock market has gradually cruised higher over the course of time as companies grow and dividends are paid.

Consider that even if you had invested at the peak of the market before the recent recession, you'd still be sitting on a gain of over 20% today based on the return of the S&P 500. But if you sold when fear was peaking in March 2009 and were only buying back in now that markets are hitting all time highs, you would have lost over 50% from the 2007 peak and recovered nothing from the rebound.

The bottom line is that market crashes can be scary, but the diversified long-term investor should ride them out, rather than give in to fear.

2. Avoid commission costs
Buying and selling investments is not free, and investors need to be aware that the more trading they do, the more commissions they'll rack up. While it may seem as if you need to trade every market movement, keep in mind that you'll need to beat the market and make up for commission costs in order to come out ahead.

Even trading once daily can cost you in the long-term. Based on Fidelity's commission rate of $7.95 for a stock trade, trading once per weekday for five years would add up to roughly $10,000 in commission costs. Even executing a trade every two weeks for 48 years -- about the length of the average career -- would cost you about $10,000 when all was said and done. Fidelity is far from the only broker that charges commissions, and some brokers charge higher commissions that will rack up costs even faster. This doesn't mean you should put your portfolio on autopilot and not make any changes to your investments, but it does mean commission costs need to be factored in every time you consider whether or not to make a move.

Whether or not you do a lot of trading, it's important to shop around for brokers that offer good investing platforms while keeping commissions and fees low. Consider that even a savings of only $1 per trade would save you well over $1,000 in the example above. Be aware of what your current broker charges in commissions and see whether other brokers offer better rates and features.

3. Be aware of expense ratios
Almost all mutual funds and exchange-traded funds charge expense ratios in order to maintain the fund and pay the people who organize it. Funds can be key to maintaining the diversification of your portfolio, but you need to be aware of their expense ratios.

Index funds require little outside management and generally have low expense ratios -- as low as 0.1% -- as a result. More specialized funds, such as international investment funds and those that hold hard-to-access securities, can carry higher expense ratios, but even these are generally less than 1%. And even those higher fees can be worth it in certain situations -- e.g., if you're looking to round out your portfolio with some broad exposure to a particular subset of equities.

But the most expensive funds are actively managed funds, which can have expenses ratios in excess of 2%. These funds are often managed by a big-name investor who claims to be able to beat the market and figures you should pay extra for that outperformance.

Despite these claims, it's incredibly difficult to beat the market over the long term, let alone to make up for these high expense ratios. Consider that a 2% expense ratio on a $10,000 investment can cost you $18,000 over the course of 20 years. Perhaps that's why Warren Buffett, though he knows countless fund managers, wants his heirs to put 90% of his money into index funds and the other 10% in short-term government bonds.

4. Don't ignore the tax man
Your total returns and taxes need to be looked at together. After all, whatever the size of your retirement portfolio, the post-tax amount is what you can actually use in retirement.

Investors should be aware that capital gains and qualified dividends generally qualify for preferential tax rates, while many other investments do not.

While gains on securities held for less than a year are typically taxed like ordinary income, gains on securities held for more than a year generally qualify for the long-term capital gains rate, which can be substantially lower, with most taxpayers qualifying for a 0% or 15% tax rate. For more information on the treatment of capital gains, see the IRS explanation. How long you hold a stock can also affect whether the dividends you receive from it are taxed like ordinary income or receive a lower rate as qualified dividends. For more information on what is and isn't a qualified dividend, see the IRS explanation.

By adjusting their holding periods, investors can qualify for lower tax rates. But considerations of tax treatment are secondary to your investment thesis -- that is, whether or not you still believe an investment is still worth holding. Here, factors including risk, portfolio balance, opportunity cost, and potential tax savings all have to be taken into account to balance your pre-tax investing strategy with what you can keep after the tax man has had his cut.

Even for sophisticated investors, the intricacies of taxes can pose a challenge of their own. You should do some basic research yourself but also be sure to consult a tax professional to better understand the tax side of your portfolio.

5. Beware too-good-to-be-true investments
You may have encountered some of these dubious investments before -- for instance, companies that pay dividends exceeding their cash flow, funds that promise to blow away the market, and get-rich-quick schemes.

Sadly, unsustainable dividends are likely to be cut, actively managed funds often charge huge expense ratios for mediocre performance, and get-rich-quick schemes prey upon unsuspecting investors every day.

Sometimes, scams can be very convincing. A recent report from Bloomberg detailed how a Forex scam used a series of video testimonials from "satisfied investors" -- who turned out to be paid actors -- and posted results showing how investors were seeing huge gains in a matter of weeks. In the end, the company shut down, taking $1 billion of investors' money down with it, after it refused to let investors withdraw any of their funds.

This case provides some important lessons for investors. First, it shows that dazzling "results" and positive testimonials are not always what they appear to be and are not solid evidence of a legitimate investing opportunity. Second, there are often red flags that signal that a company is being deceptive. In this case, the company never revealed its true location and promised returns of about 250% annually. Third, the results investors were seeing in their accounts were not real, so don't blindly trust the posted results and pour money in.

Remember: When something promises extreme upside, it likely comes with a lot of risk, so the more upside is promised, the more research you should do to confirm that it's not a "too good to be true" situation. As in so many other areas of investing, make sure you know what you own, and if an investment opportunity cannot answer all your questions, it's probably best left alone.

Avoiding mistakes
Being aware of risks and opportunities is key to taking control of your retirement portfolio. Expenses, such as commissions and taxes, need to be understood and planned for to make sure you save every penny you can toward your retirement goal.