When the Dow crosses a thousand, it usually means a new rally

The Dow Jones industrial average has been hovering at all-time highs and just crossed 20,000 for the first time. If history is any guide, that psychological multizero barrier suggests more gains are to come.

CNBC looked at market data from the past 30 years and zeroed in on the times when the Dow has crossed levels like 2,000, 3,000, 4,000 ... all the way up to the 19,000 level it hit in November. At those times, investors can typically expect traders to push it up even higher, according to data from Kensho. Not only does the Dow go up, but it outperforms the S&P 500 index along the way.

The trend is true not just for quick one-week returns, but also for one-month and one-quarter. Here's a summary of the data, going back to January 1987, when the Dow closed above 2,000 for the first time. Averages over the 18 instances show how performance increased.

In fact, it was just two months ago when the Dow was at 19,000 that we used a similar analysis and predicted it would likely go higher.

On a one-month basis, the Dow has outperformed the S&P 500 index 14 of those 18 times. In the month after hitting 19,000, the Dow again beat the S&P by 2 percent.

Those -000 multiples get extra attention in the media (like this article), encouraging more people to jump on board. Such mental and optical effects also play a part in technical trading, where investors focus on chart movements and specific levels of "support" and "resistance." Breaking through any -000 number is a real, psychological event that people can flock toward to push assets even higher.

A market move through a -000 level also suggests a shift on the chart. Levels that had been considered resistance (psychological barriers against going higher) turn into levels of support (barriers against dropping lower). Consider the scenario we were just in: A Dow below 20,000 pushing up on that ceiling. Now that we've broken through, it has just blue sky and room to run.

Consider the example from mid-2007, when the Dow closed above 13,000 for the first time. You can see how the Dow then took off relative to the S&P 500, outperforming by almost 4 percent in just three months.

Disclosure: NBCUniversal, parent of CNBC, is a minority investor in Kensho.