"As we get temporary spikes in volatility, ... these will continue to be buying opportunities because the fundamentals have been so strong," said Randy Frederick, vice president of trading and derivatives at Charles Schwab, noting that the latest earnings season exceeded expectations and economic data remained solid.

Last Wednesday, stocks dropped more than 1 percent on the back of fears that Trump's pro-growth agenda may be in danger. Reports that Trump allegedly tried to influence a federal investigation sent shivers down Wall Street.

The Nasdaq composite eked out a small gain despite Apple slipping. But the three major indexes notched a four-day winning streak, extending their bounce following the biggest sell-off of the year.

The S&P 500 also ended higher and nearly erased the losses suffered from the biggest sell-off of the year. The index rose 0.2 percent to come about 2 points of closing above the Tuesday, May 16, close of 2,400.67.

Stocks closed higher on Tuesday as hope around the Trump trade was renewed among investors.

Wall Street kept an eye on Trump's first trip overseas since taking office. The president met with Palestinian President Mahmoud Abbas and also met with Israeli Prime Minister Benjamin Netanyahu. The U.S. president will be in Europe for the rest of his trip.

Trump's "trip overseas is definitely helping. Not so much so because of what he's done, but because he is tied up and doesn't have time to cause problems," said Schwab's Frederick.

Investors also paid attention to the White House's proposed budget for next year. In it, the White House is seeking to cut federal spending by $3.6 trillion over the next 10 years.

The budget also assumes the administration will be able to lower taxes for businesses and households. The potential of lower taxes has been a boon for stocks since Trump's election, along with possible deregulation and infrastructure spending, as the major indexes have broken into record territory.

"Most of the rhetoric out of the budget and Trump's trip overseas has not been negative," said Jeff Zipper, managing director of investments at the Private Client Reserve of U.S. Bank. "It's positive that Washington is discussing his agenda. We'll see how much of that gets passed."

But traditional safe havens have caught a bid recently. The benchmark 10-year note yield falling to around 2.28 percent from its highest levels near 2.62 percent as investors prepared for the possibility that tax reform may not come as soon as previously thought.

Gold prices have also risen. The metal's 50-day moving average crossed above its 200-day moving average on Monday, potentially signaling more gains.

In Europe, stocks traded mostly higher despite an attack that killed at least 22 people and injured dozens at an Ariana Grande concert in Manchester.

The terrorist attack has dragged sterling marginally lower and led Prime Minister Teresa May to suspend her election campaign ahead of the June 8 election.

"It's a good thing that financial markets are holding up on the back of these attacks because if people panicked then it could be a bigger incentive for terrorists to attack more," said Nick Raich, CEO of The Earnings Scout.

In economic news, new home sales fell 11.4 percent in April to a seasonally adjusted annual rate of 569,000. Economists polled by Reuters had forecast new home sales would decrease by 1.5 percent to 610,000 units.

Historically, such large misses in new home sales have led to trouble for stocks. According to Kensho, S&P returns average negative 2.86 percent a month after new home sales miss by 50,000 or more. Returns for the SPDR S&P Homebuilders ETF (XHB) and the Consumer Discretionary Select Sector Fund ETF (XLY) fall 3.44 percent and 2.6 percent, respectively.

Later this week, the Federal Reserve will release the minutes from its May meeting, with investors hoping to get more clues about the central bank's plans for monetary policy.

"We certainly believe there will be a rate hike in June," said John Stadtler, head of U.S. Financial Services at PwC. "The June meeting gives them the opportunity to give feedback about what they are thinking."