U.S. stocks closed higher Tuesday, with energy stocks leading as crude topped $42 a barrel, as investors awaited the bulk of earnings due over the next few weeks.
The S&P 500 closed nearly 1 percent higher to recover positive territory for the year so far. Energy closed up 2.8 percent as the top advancer.
"I think it's following oil and getting through the 200-day on WTI was pretty important," said Jeremy Klein, chief market strategist at FBN Securities.
"Dollar-yen is finally breaking its losing streak and doing it with gusto," he said.
WTI hit a fresh high for the year so far and settled at its highest since late November, at $42.17 a barrel, up $1.81, or 4.48 percent. U.S. crude oil futures topped their 200-day moving average for the first time since July 2014.
Oil extended earlier gains in mid-morning trade after Bloomberg, citing Interfax, reported that Saudi Arabia and Russia have reached a consensus on oil freeze. Bloomberg later reported the Russian energy ministry declined to comment on the report.
The gains in oil prices also helped financial stocks ahead of major bank earnings due later in the week. Financials was the second-best S&P performer, with the SPDR S&P Bank ETF (KBE) closing up 2.06 percent for its best day since March 11 and third-straight day of gains.
The Japanese yen continued to pull back from recent highs against the U.S. dollar, last at 108.5 yen for the greenback's first gain against the yen in April.
The U.S. dollar index was mildly higher with the euro near $1.139.
Treasury yields edged higher, with the near 0.73 percent and the 10-year yield around 1.77 percent.
"It seems just to be better risk sentiment to me," said Brandon Swensen, co-head of the fixed income desk at RBC Global Asset Management. "Looking across the board the risk-off fears are abating a bit."
The major stock indexes briefly gave up opening gains before extending gains as oil climbed.
"This is a tug of war going on between the bulls and the bears. You get profit-taking heading into earnings season. People get nervous," said Marc Chaikin, CEO of Chaikin Analytics.
The Nasdaq composite briefly turned lower as Starbucks temporarily declined more than 3.5 percent before closing 2.3 percent lower. Deutsche Bank downgraded the stock to "hold' from "buy" based on "lofty near-term investors' expectations" and "premium valuation."
"Earnings are kind of in a lull. The Fedspeak later in the day doesn't really matter because we know where they stand," Klein said. "It will be interesting to see today if there's another late-day sell-off."
The Dow Jones industrial average rallied more than 150 points on Friday and Monday only to reverse and close slightly higher or lower. The S&P 500 lost 5.61 points Monday to end in negative territory for the year so far, with consumer staples leading eight sectors lower.
"The S&P futures are range-bound from an intraday perspective, with each step forward seemingly met with one step back," BTIG Chief Technical Strategist Katie Stockton said in a morning note.
"The fickle price action reflects a loss of short-term momentum, which is made more concerning by widespread intermediate-term overbought conditions," she said. "A pullback has unfolded globally and short-term oversold conditions are still not widespread, affecting only 22 percent of the S&P 500 by our measures."
In economic news, March import prices showed a 0.2 percent rise from the prior month for the first time in nine months, although the gain was well below the expected 1 percent rise. Export prices were unchanged.
U.S. small business confidence fell to a fresh two-year low in March at 92.6, amid persistent worries about sales and profits, Reuters said, citing the National Federation of Independent Business.
The major economic data due in the next few days include retail sales and inflation reports.
Early Tuesday, the International Monetary Fund trimmed its global growth forecast to 3.2 percent for 2016.
Speaking on CNBC's "Squawk Box" Tuesday morning, Dallas Fed President Robert Kaplan said the U.S. economy is likely to grow at just under 2 percent for the year. He also said the financial turmoil at the beginning of the year may have had more of psychological impact on consumers than previously thought.
Kaplan said Monday it is too soon for an interest rate hike in the United States, but he is open to a rate hike in June.
Three other Fed officials spoke on Tuesday. Philadelphia Fed President Patrick Harker said in a Reuters report he supports raising rates again as the U.S. economy strengthens. He added it is still possible for the Fed to raise rates three times this year if the data allows.
Separately, San Francisco Fed President John Williams said in a Reuters report that with data on the U.S. economy coming in generally as expected, the Fed is on track to raise interest rates two or three times this year, He added he does not expect much market turmoil when rates do rise.
Richmond Fed President Jeffrey Lacker said recent signs that U.S. inflation is accelerating give the Fed a good reason to raise interest rates, Reuters reported.
Alcoa reported adjusted first-quarter earnings of 7 cents a share, topping expectations of 2 cents a share. However, revenue of $4.95 billion missed expectations of over $5 billion and the aluminum producer also announced job cuts. The stock closed down 2.67 percent.
European stocks closed half a percent higher or more, with banks underperforming.
Overnight, the Shanghai composite closed 0.3 percent lower, while the Nikkei 225 gained 1.1 percent.
The Dow transports closed up 0.77 percent with Landstar leading most constituents higher.
The closed up 19.73 points, or 0.97 percent, at 2,061.72, with energy leading all 10 sectors higher.
The Nasdaq composite closed up 38.69 points, or 0.80 percent, at 4,872.09.
The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, fell to near 15.
About four stocks advanced for every decliner on the New York Stock Exchange, with an exchange volume of 953 million and a composite volume of 4.1 billion in the close.
Gold futures for June delivery settled higher, up $2.90 at $1,260.90 an ounce.
On tap this week:
Earnings: CSX, Adtran
3 p.m. San Francisco Fed President John Williams
4 p.m. Richmond Fed President Jeffrey Lacker
Earnings: JPMorgan Chase, Commerce Bancshares, Pier 1 Imports, Kinder Morgan, Noble
8:30 a.m. Retail sales; PPI
10 a.m. Business inventories
10:30 a.m. EIA oil inventories
1 p.m. $20 billion 10-year note auction
2 p.m. Beige book
Earnings: Bank of America, BlackRock, Wells Fargo, PNC Financial, First Republic Bank, Freeport-McMoRan, Snap-on, Advanced Micro, Delta Air Lines, Shaw Communications, Infosys
8 a.m. Bank of Japan Governor Haruhiko Kuroda at CFR, New York
8:30 a.m. Jobless claims
8:30 a.m. CPI
10 a.m. Atlanta Fed President Dennis Lockhart
10 a.m. Fed Gov. Jerome Powell at Senate Banking subcommittee
1 p.m. $12 billion 30-year bond auction
Earnings: Citigroup, Charles Schwab
8:30 a.m. Empire State survey
9:15 a.m. Industrial production
10 a.m. Consumer sentiment
12:50 p.m. Chicago Fed President Charles Evans
4 p.m. Feb TIC data
*Planner subject to change.
More From CNBC.com: