Dollar-cost averaging is essentially an investment strategy that allows you to build your portfolio over time by purchasing a set dollar amount in stocks at regular intervals, rather than purchasing your holdings all at once at a single price. That way, you'll buy more when the stock is cheap and less when it is expensive.

Over the long run, dollar-cost averaging works in your favor by lowering per-share cost of your investments, which can make a big difference in your returns.

For example, let's say I have $3,000 to invest, and I want to buy a certain stock that's trading for $25 per share. Instead of buying $3,000 worth of shares immediately, I invest $1,000 per month for three months.

My first $1,000 is invested when the share price is $25, so I buy 40 shares. If the share price drops to $20 the following month, my next $1,000 buys 50 more shares. If the stock has a great month after that and rises to $30, I only buy another 33 shares for my last $1,000. At the end of the process I own 123 shares of the company.

Here is the most important point: Even though the stock traded for an average price of $25 during the three months ($20, $25, and $30), my average cost per share is just $24.33, as I bought the most shares at the lower prices.

While this is a simplified example, it shows how buying a position over a period of time can provide an excellent average price per share, and it eliminates the need to try to time the market and find the best possible entry point.

Source: via Flickr.

Why it's better than buying set numbers of shares
In the above example, if I had instead simply bought, say, 50 shares per month, it would have produced a higher average share price of $25.

In fact, thanks to the laws of mathematics, investing a set dollar amount each time will always produce an equal or lower average share price than buying a set amount of shares each time. To see this firsthand, just repeat the above example with any three hypothetical stock prices and investment amounts.

Timing the market is never a good idea
However, what if I had just bought all of the shares for $20 -- the lowest of the three share prices? Sure, that would have produced an even better cost basis, but trying to time the market rarely works in the investor's favor.

Even the most seasoned professionals know that trying to determine when the market or stock has reached a bottom or top is a losing battle. It's a bad idea to go against market trends by using such as logic as "Well, this stock can't possibly get much cheaper -- it must be a good time to buy."

Market timing is one of the main reasons why average investors tend to realize far lower returns than they would have achieved by employing a "buy and hold" strategy. In fact, one study found that the average investor produced annual returns of just 3.5% over the 20-year period ending in 2011, while the S&P 500 more than doubled this rate with an average annual return of 7.8%.

When you hear predictions in the news that a market correction is imminent, that the Dow Jones Industrial Average is heading to 20,000, or some other theory about where the market is heading, the best thing is to ignore them. Instead, focus on buying quality companies that will withstand the test of time. If you do this and incorporate a dollar-cost averaging strategy, you'll produce strong returns over the long run while still being able to sleep at night.