History says the stock market’s dismal October points to a rally over the next 6 months