If history is a guide, the going will continue to be good for stocks into the end of the year.

The S&P 500 is on track for a 3.5 percent gain for the third quarter, having dodged sell offs in the often weak months of August and September. The market’s performance in those two months now bodes well for more gains in the fourth quarter, which begins Monday.

“Whenever the S&P 500 has been up in August and September, two months that are usually very challenging for stocks, the S&P has risen in price 13 of 16 times, or 81 percent of the time, for the remainder of the year,” said Sam Stovall, chief investment strategist at CFRA.

In those years when August and September are both positive, the index averaged a 2 percent gain in the final quarter of the year in the 16 occurrences since World War II.

The S&P is up 1.6 percent in September, so far, and was flat but just barely higher in August, with a 0.05 percent gain. The S&P 500 closed at 2,510 Thursday, a point below its all-time high, but the Russell 2000 closed at an all time high of 1,488.

Earnings should continue to be a positive for the market, and the Republican tax plan, announced Wednesday, could also be a catalyst in the fourth quarter, Stovall said. He estimates if approved, it could add five to 10 percent to earnings growth in 2018, which he had expected to be up about 10 percent.

“That’s a positive because back of the envelope estimate says for every 1 percentage point cut in the tax rate could add a percent to earnings in that calendar year,” said Stovall. The proposed tax rate for corporations is now 20 percent, down from 35 percent, but the average tax rate that S&P 500 companies actually pay is closer to 25 percent.

“Small caps are doing well since they would benefit from a tax cut and since their earnings are domestic,” Stovall said.

Stovall said the S&P has also performed well in the usual ‘sell in May’ period which starts in May and goes until the end of October. It is up 5.2 percent in that period so far, and if it ends October with a gain there are also good chances the market carries on its rally through year end, he said.

“It normally does pretty well if you have end of the year enthusiasm,” he said.

But Scott Wren, senior global equity strategist at Wells Fargo Investment Institute, said he’s not in the camp that sees stocks going higher into the end of the year. His target is for 2,350 on the S&P, and he thinks it will decline.

“With the tax thing, there’s lots of ‘ifs’ and I’m not confident we’re going to get through negotiations in any sort of timely fashion,” said Wren. “There’s still plenty for Congress to disagree on. I think it’s going to move slowly and it’s likely to be watered down from whatever we’ve seen so far.”

Wren also expects earnings to grow slower than they had earlier in the year, with a 5 to 7 percent gain for the third quarter.

“I think still, for us, these valuations are stretched. At least, you’re looking at a 20 time trailing number on the S&P and that’s against a 30 year median of 16.5 percent, or somewhere in there. I think the Fed is going to hike in December,” he said, adding rate hikes could become a head wind next year.

“We’re still watching for a 4 to 6 percent pullback by the end of the year or into early 2018. We’ll end up with 5 to 8 percent return this year,” he said.

Stovall said his 12-month target for the S&P is 2,640, and he thinks the market could run into trouble around the second quarter of 2018.

“I think we might end up seeing the second and third quarter of the mid-term election year look like it normally does, which are the most challenging quarters of the presidential cycle. I think if we do get a tax cut that would already be baked in to share prices. What we’re going to do is face an awful lot of uncertainty regarding mid-term elections,” Stovall said.