The rise of artificial intelligence (AI) ushered in a period of historic gains in the stock market. The stock market is trading near record levels, and history suggests a reversal could be in store.