Art Cashin CNBC UBS's Art Cashin rang the New York Stock Exchange's opening bell on December 30 to mark his 50th year trading on Wall Street.

So, what kind of wisdom does this veteran have for us after all that he's seen?

He shared a time-tested strategy in an interview on CNBC:

"...one of the key things that people can do, particularly if they're starting their investment plan, there's something called dollar-cost investing, in which you set aside a certain amount of money, $200, $500, and you buy it every specified day. Every month, or every six months. And that way, if stock prices are down, you wind up with more shares, and if stock prices are too high, you don't buy as much. So, dollar-cost averaging works out pretty well, and yes, the stock market continues to be a good investment."

Cashin said this even as the S&P 500 was trading within points of an all-time high.

The brilliant thing about dollar-cost averaging is that it works very well even if the market is at a top.

We ran the numbers to see how an investor would've done had she started a dollar cost-averaging strategy right before the last market crash.

There's A Correct Way To Buy Stocks If You're Convinced The Market Will Crash

The stock market is great for investors who have the benefit of long-term investing horizons. It's also better-suited for investors who aren't concerned about perfectly-timing market tops and bottoms.

Having said that, taking a longer term view is good for investors worried that they may be buying at the top of the market.

A classic strategy called dollar-cost averaging can help reduce risks surrounding an asset falling in price. As described by Cashin, the concept is straightforward — you invest a fixed amount of money in an asset once every fixed time period. If the asset's price drops, you will be getting more shares of the asset for the same amount of money, and so if and when the price recovers, you will have spent less per share, on average, than if you had bought the shares at their peak, pre-fall price.

Dollar-cost averaging isn't about losing money as the stock market falls. It's about buying increasing amounts of shares at cheaper prices, which means bigger returns during the rally.

How Dollar-Cost Averaging Worked Brilliantly During The Last Crash

To see this in action, we came up with a simplified thought experiment.

We considered what would have happened to an investor jumping into the stock market at the last peak: October 2007. This was arguably the worst time to buy. Our hypothetical investor puts $50 into a S&P 500 index fund at the start of every month, starting in October 2007 — the last stock market peak before the beginning of the great recession.

Here is what happened to the S&P 500 starting at that peak:

Business Insider/Andy Kiersz, data from Yahoo Finance

The index dropped more or less steadily until the worst moments of the financial crisis in fall 2008, causing the full on crash, and only began to turn around in March 2009.

The key to our investor's experiment is that they are staying consistent. No matter how stock prices move, they will always put $50 on the first trading day of every month into the index fund.

Based on changes in the value of the S&P 500 index, we calculated our investor's price return, less the $50 monthly cost:

Business Insider/Andy Kiersz, data from Yahoo! Finance

The value of our investor's portfolio as of December 1, 2014 is $6,896.30. If they instead had taken their $50 each month and held it as cash, they would have just $4,350. So, the price return on this investment — even though they started at the last peak, just before the market started to go downhill — is $2,546.30.

This is a respectable 58.5% return. That averages out to about a 6.6% annual rate of return.

To get another perspective on this, here is the percent gain or loss, compared to taking $50 each month and holding it as cash:

Business Insider/Andy Kiersz, data from Yahoo! Finance

Things start out looking pretty dire, as the economy fell into its deep recession through mid-2009, with the S&P 500 reaching a minimum in March of that year. At the lowest point for our investor, at the start of February 2009, she would be down about 36%.

Because human beings are often overly risk-averse, our hypothetical investor might have been tempted to abandon their investment plans during the bad months. That is, they might look at this chart and panic about the drop:

Business Insider/Andy Kiersz, data from Yahoo! Finance

But, if our investor sticks with their plan and keeps putting $50 in every month, even through the dark times, once the market bounces back, they end up doing quite well:

Business Insider/Andy Kiersz, data from Yahoo! Finance

Here's Why You Never Hear About This

Unfortunately, dollar-cost averaging isn't sexy. It's much sexier to sell at the top and buy at the bottom.

Obviously, your returns would be much higher if you win the stock market lottery by perfectly timing the tops and bottoms of the market. However, almost everyone who tries to do this will find themselves losing money and lots of it.

If you are investing for the long haul, and can hang on through watching your portfolio's value drop temporarily in bad times, starting to invest in stocks, even near a peak, may not be as terrifying as it looks. The market has always bounced back sooner or later, so if you can hold on until that later, don't panic.