*

* Nasdaq, S&P 500 post fourth weekly gain

* S&P 500 recovers 50% of bear market losses

NEW YORK, Aug 12 (Reuters) - Wall Street closed higher on Friday as signs that inflation may have peaked in July increased investor confidence that a bull market could be under way and spurred the S&P 500 and the Nasdaq to post their fourth straight week of gains.

The S&P 500 is up 17.5% from a mid-June low, with the latest gains coming from data this week showing a slower-than-expected rise in the consumer price index and a surprise drop in producer prices last month.

The S&P 500 crossed a closely watched technical level of 4,231 points, indicating the benchmark index has recouped half its losses since tumbling from its all-time peak in January. A 50% retracement for some signals a bull market.

"It's really just a number, but it certainly makes investors feel better - at least those who bought near the bottom," said Tim Ghriskey, chief investment strategist at Inverness Counsel in New York.

"I wouldn't declare victory over this bear market yet. There's likely some bad news still out there. But there's a very good chance we've seen the bottom."

According to preliminary data, the S&P 500 gained 72.13 points, or 1.71%, to end at 4,279.40 points, while the Nasdaq Composite gained 265.14 points, or 2.07%, to 13,045.05. The Dow Jones Industrial Average rose 418.64 points, or 1.26%, to 33,755.22.

As the S&P 500 and Nasdaq posted the longest weekly winning streaks since November, analysts noted the Federal Reserve still has its work cut out as it tries to tame inflation by aggressively raising interest rates without sparking a recession.

"Markets certainly got great news this week on inflation," said Dec Mullarkey, managing director of investment strategy and asset allocation at SLC Management in Boston.

"A victory lap in some respects was in order, but it's not 'mission accomplished' by any means. It's still a very slow grind ahead."

Inflation by year-end might decelerate to 7% or a bit lower, but getting core inflation under 4%, which is double the Fed's target, will be tougher than markets anticipate, Mullarkey said.

Traders are pricing in a less hawkish Fed, with fed fund futures showing a 55.5% chance of Fed policymakers raising rates by 50 basis points when they meet in September, instead of 75 basis points.

It was a sea of green on Wall Street for a second straight day, with all 11 major S&P 500 sectors rising, along with semiconductors, small caps and Dow transports . Growth stocks rose more than value stocks.

Investors bought $7.1 billion in equities in the week to Wednesday, according to a Bank of America note, with U.S. growth stocks recording their largest weekly inflow since December last year.

Banks rose to extend their rally for a sixth straight week. Also driving optimism was data showing U.S. consumer sentiment ticked further up in August from a record low this summer and American households' near-term outlook for inflation eased again on softening gasoline prices.

After a rough start to the year, better-than-expected second-quarter earnings from Corporate America have supported the upbeat sentiment for U.S. equities.

Analysts in aggregate believe the S&P 500 posted year-over-year earnings growth of 9.7% in the April to June period, much stronger than the 5.6% predicted at quarter-end, per Refinitiv.

GlobalFoundries Inc jumped on being added to BofA Global Research's "U.S. 1 list."

(Reporting by Herbert Lash in New York Additional reporting by Bansari Mayur Kamdar and Aniruddha Ghosh in Bengaluru; Editing by Arun Koyyur and Matthew Lewis)