Forget the polls. Wall Street has another way to predict whether Donald Trump or Hillary Clinton will be the next president of the United States.

Keep an eye on the stock market from August 1 through October 31.

If stocks go up during that three month stretch, expect Clinton to win. If stocks slide, Trump will likely prevail.

Those critical three months have been astonishingly accurate at predicting the next president, says Sam Stovall, a stock market expert at S&P Global Market Intelligence.

Stovall looked at the data for every presidential election going back to 1944 (FDR v. Dewey). If stocks rose in price from July 31 to October 31, the party that currently controlled the White House won the election 82% of the time.

This year, the key stretch will start on August 1, since July 31 is a Sunday.

Related: Hillary Clinton's new problem

Similarly, if stocks (measured by the S&P 500 index that tracks the performance of 500 of America's largest companies) fell, voters opted to kick out the party in power and replace it 86% of the time.

"We all know that prices lead fundamentals. And more times than not, S&P 500 price returns identified whether the incumbent president, or his party, was reelected or replaced," wrote Stovall in his report on elections and the market.

The basic idea is that if the economy is growing and people think the good times will continue, they are likely to want to stick with the same presidential party (in this case the Democrats). If they are fearful, stocks tend to fall, and voters want new leadership.

The only times that the stock market predictor didn't work were in years where a strong third party candidate was involved (e.g. 1968 or 1980) or when there was a surprise geopolitical shock like 1956 when England and France seized the Suez Canal from Egypt.

Related: Investors prefer Clinton over Trump

The third party factor could be make Election 2016 more difficult to predict too. Libertarian Gary Johnson has been polling around 10%.

The stock market is coming into the "presidential predictor stretch" near all-time highs. Wall Street experts have very mixed views on whether it can go up more from here.