Image: U.S. flag and currency © Steve Allen, Brand X, Corbis

A lot of people think that Election Day results foretell how the stock market will behave in the coming months and years. A Mitt Romney victory, some believe, would be good for stocks. After all, Republicans are friendlier to Wall Street than are Democrats.

But there's no historical evidence to support this notion. Indeed, since 1928, the stock market has produced ever-so-slightly better results, on average, when Democrats occupy the White House. The median price gain for Standard & Poor's 500 Index ($INX) during Democratic presidencies has been 27.5%, compared with 27.3% during Republican administrations, according to the Leuthold Group, a Minneapolis investment research firm.

Not only that, but Barack Obama -- cast by Republicans as an enemy of free enterprise -- has presided over one of the strongest stock markets since 1928. If the S&P 500 closes above 1,443 on Inauguration Day, the market's performance during Obama's first term will rank second-best of all time, behind only the results during the first term of another supposed archfoe of business, Franklin D. Roosevelt.

No, if you want to forecast the stock market, look at price-earnings ratios, consider the troubles in Europe and China, examine analysts' earnings predictions, worry about the fiscal cliff. Look at anything except presidential polls.

But if you're a political junkie like me, you'll want to use the stock market to predict who will win the election. That is something the market excels at.

Jim Stack, the editor of the InvesTech Research investment newsletter, has crunched the numbers. His findings? Since 1900, the direction of stock prices in the two months prior to Election Day has predicted the winner 89.3% of the time. "A rising stock market indicates an improving economy, which means rising confidence and increases the chance of an incumbent's re-election," he says.

Even the market's bad calls were in years when the market didn't move much in the two months before Election Day. In the three elections during which the indicator failed, the Dow Jones Industrial Average ($INDU) moved 3.1% or less during the two-month period.

The main shortcoming of Stack's work is that you can't tell the outcome until Election Day. People like me want to know sooner.

Fortunately, Sam Stovall, the chief stock strategist at S&P, uses an indicator with a longer lead time. Looking at S&P 500 prices since 1900, he has found that the market action between July 31 and Oct. 31 has correctly forecast the outcome of the presidential campaign 82% of the time.

So how are Romney and Obama doing on Wall Street? The S&P closed at 1,379 on July 31 and was trading about 1,457 on Sept. 24. That's a gain of 5.2%. The market would have to drop at least 4.95% in four weeks for Romney to win -- assuming that this indicator is on the money this year.

Of course, the indicator was wrong 18% of the time. In 1912, Democrat Woodrow Wilson unseated Republican President William Howard Taft despite a rising market in the pivotal three-month period. The market also gained ground in 1932, even as Roosevelt, a Democrat, defeated Republican incumbent Herbert Hoover amidst the Great Depression. The market fell in 1956, but Republican Dwight Eisenhower still was re-elected. President Richard Nixon beat his Democratic rival, Hubert Humphrey, in 1968 despite a rising market, and Republican challenger Ronald Reagan ousted Democratic President Jimmy Carter in 1980, even as the market climbed.

Stovall postulates that third parties may have played havoc with his indicator. Teddy Roosevelt ran as a Bull Moose candidate in 1912, George Wallace ran as an independent in 1968, and John Anderson, another independent, took some votes from Carter in 1980. But the indicator was just plain wrong in 1932 and 1956, Stovall concedes.

In a year during which pollsters can get only about one in 10 voters to pick up the telephone to answer questions, the stock market indicator looks like a pretty good bet. I'll be watching to see how it turns out -- and, of course, with much more interest, how the market does under the winner.

Click here to become a fan of MSN Money on Facebook

More from Kiplinger's Personal Finance magazine: