Stocks vacillated between gains and losses on Thursday before ending the trading session in positive territory. Both the Dow Jones Industrial Average (^DJI 0.37%) and the S&P 500 (^GSPC 0.86%) edged higher to keep their year-to-date returns at 7%:

Today's stock market:

Index

Percentage Change

Point Change

Dow

0.13%

23

S&P 500

0.22%

 5

Data source: Yahoo Finance.

Individual stocks making market-beating moves on Thursday included Wal-Mart (WMT -1.40%) and NetApp (NTAP 0.64%).

Wal-Mart's customer traffic streak

Wal-Mart was the Dow's best performer, rising 2% after announcing solid second-quarter earnings results. Comparable-store sales improved by 1.6% (nearly twice management's forecast), which helped drive revenue and profit figures that beat consensus estimates.

Key to that success was the retailer's booking its eighth straight quarter of customer traffic gains, which stood in contrast to rival Target (TGT -0.13%), which earlier in the week posted its first quarterly traffic drop in two years.

Image source: Wal-Mart.

Wal-Mart managed several other operating wins this quarter, including higher gross profit margin, lower inventory levels, and a greater contribution from the e-commerce segment. "We're pleased with the positive momentum in our business," CEO Doug McMillion said.

On the other hand, expenses rose as the company plowed cash into delivering higher in-stock levels in stores and paying associates higher wages.

Investors can expect this spending to continue, especially now that it appears the investments are driving improved customer traffic. Cash outlays are also slated to creep higher on Wal-Mart's e-commerce initiatives like its $3 billion acquisition of Jet.com.

Still, the company boosted its full-year earnings forecast and said that it sees the positive traffic trends continuing into the current quarter, where comps should be about 2%. That streak should give the retailer solid momentum headed into the critical holiday shopping season. 

NetApp's slimming cost structure

Data management specialist NetApp saw its stock surge higher by 16% following surprisingly strong earnings numbers. Revenue held steady at $1.3 billion, but a drop in product costs, combined with sharply lower operating expenses, drove significant profit improvements.

Image source: Getty Images.

NetApp generated $129 million of net income compared to $89 million in the year-ago period. That translated into $0.46 per share of earnings, which outpaced consensus estimates calling for $0.36 per share. "Our focus on disciplined execution of our strategy is yielding results and starting to change the trajectory of our business," CEO George Kurian said.

NetApp has plenty of challenges to face. An overall weak IT spending environment is pressuring pricing, for one, and investors can see that reflected in a non-GAAP gross profit margin that fell by nearly a full percentage point. It's also unclear how well the company can execute as it cuts spending in critical categories such as sales and marketing and research and development.

Kurian and his team believe the cuts don't threaten future growth, but instead are part of a necessary shift to a more streamlined business. They don't compromise NetApp's "ability to deliver innovation and lead the market," executives told investors on a conference call. In the meantime, the company is trying to pivot to higher growth areas such as flash data centers so that it can return to sales growth following three years of declines.