President Donald Trump talks to reporters as he departs on travel to Argentina from the White House in Washington, November 29, 2018.

If the stock market is going to end the year with gains, it could all come down to this weekend and the meeting between President Donald Trump and China President Xi Jinping.

Stocks have been whipped by headlines on trade, and on Thursday alone the market was encouraged by comments from Trump that he wanted a deal but then disappointed when he said he wasn't sure he would agree to one. Equities also fell because of reports that Trump trade advisor Peter Navarro, a China hawk would be in attendance at the dinner meeting Saturday night. But then the market bounced on a Wall Street Journal report that said the U.S. and China were exploring a deal where the U.S. would hold off of further tariffs until spring, to allow for negotiations.

"The market is pricing in some degree of further escalation, breakdown of talks. If we have an agreement, then you price out the downside," said Keith Parker, head of U.S. equity strategy at UBS.

Many analysts believe the two sides could announce they will negotiate, somewhat calming the market, but the U.S. will likely increase tariffs as expected, to 25 percent in January. Strategas Research gives this scenario 40 percent odds.

But if Trump agrees to hold off on increasing those tariffs, now 10 percent on $200 billion in Chinese goods and agrees to hold off putting tariffs on a wider group of goods as talks proceed, that could be a big positive for stocks.

Strategas gives this scenario 30 percent odds, and if there's an even better deal where there are no new tariffs and some are removed, the odds fall to 20 percent. In a note, Strategas saw just a 10 percent chance of absolute failure.

Trade and the Fed have been the two big fears hanging over the market, as it has sold off in October and November. After a 4.3 percent bounce back this week, the Dow is now up nearly 2.5 percent for the year. It surged more than 617 points Wednesday, after Fed Chairman Jerome Powell said the fed funds rate was close to neutral, meaning interest rates do not need to be raised much more.

The S&P 500, ending Thursday at 2,737, is up 4 percent for the week and is now up 2.4 percent for the year.

"To me the Powell comments were above and beyond what I expected. The market is pricing that in, and if there's a 25 percent tariff off the table that's worth 1.5 to 4 percent in equities, based on our earnings model," said Parker.

If instead, talks breakdown and the U.S. moves forward on further tariffs, the S&P 500 could slide about 200 points to 2,550, Parker said.

"My theory is that the markets are having tremendous influence on Jay Powell and on Donald Trump. I don't think Powell blinked because of Trump. If Powell blinked, it was because of the market and I'd make a similar comparison to the markets and trade. The markets have sent a clear signal," said Greg Valliere, chief global analyst at Horizon Investments.

Valliere said he believes Trump is more sensitive to the market's moves. "I think the market blowback to Trump's trade policies took him aback. I think he feels he's going to get something out of Buenos Aires. The question is, 'what is something?' The very least is a good atmospherics, a good photo op, a nice dinner. They superficially get along? I think they need to issue a statement they are planning to speed up the pace on talks and try to get a resolution," said Valliere.

"The ultimate bargaining chip is to back away from the additional 25 percent tariffs at the end of the year," he said. "I've thought all along that would be part of an agreement in Buenos Aires. Just as Powell listened to the markets, I think Trump listens to the markets. I think on both Fed policy and China trade policy, the markets will have gotten their way. The markets should be pleased with both Powell and Trump listening to their message."

As for a trade deal, Valliere said it could take a while and come later in the year. "China is a very proud country, and it will take many months to get a deal," he said.