The S&P 500 had a great October and is up more than 20% for the year, which is a good omen for the remainder of 2019 and the new year ahead.

Looking back to the 1950s, the average return for the S&P 500 in November and December is better than 6% — and has never posted a loss — when the index is above 20% through October. It has happened seven times since 1954 and the median isn’t much lower at 5.92%, according to Canaccord Genuity.

Optimism surrounding the trade war between the U.S. and China, interest rate cuts from the Federal Reserve and surprisingly good corporate earnings reports are fueling a stock market rally that saw the Dow Jones Industrial Average hit a new record high Monday. The S&P 500 also recorded another record high last week.

The market is seemingly shrugging off some trade war negativity and recession signals like the yield curve inversion that happened several times earlier this year.

Canaccord Genuity analyst Tony Dwyer points to strong economic activity driving earnings season, which leads to the rallies investors have seen lately.

“Over the long-term, the equity market is most closely correlated to the direction of earnings,” Dwyer said in a note to clients, according to CNBC. “The continued positive trajectory of EPS and low inflation should cause a continued multiple expansion.”

Pullback shouldn’t be much of a concern, either. When the S&P 500 enters November with gains over 20% for the year, the average pullback is only 1.37% and the median is under 1%.

“The message is clear — use any pullback as an opportunity to add exposure,” Dwyer said.

Prospects should be good for 2020 as well if the trend follows historical data. Canaccord’s analysis shows the average returns for the year after a strong finish were 15.11% and the median return was 19.15%.

Only time will tell if the markets repeat history and give investors a strong finish and happy start to the new year.