Oil prices continues to gain.

As equity markets headed toward their third weekly decline this month, oil prices moved in the opposite direction, with West Texas Intermediate crude futures set to close out a second straight week of gains Friday on signs that oil inventories are falling even as U.S. drilling activity is increasing.

U.S. producers brought five rigs online last week, raising the total to 995 overall, Baker Hughes (BHGE - Get Report) reported on Friday. Oil rigs rose by four from the previous week to 804, while gas rigs are up by one to 190. 

Rigs are now up 186 year over year from 809, with oil rigs up 152, gas rigs up 35 and miscellaneous rigs down one. Last week the count climbed by six rigs. 

The recent uptick in U.S. drilling is offset by positive data on the country's stockpiles of crude out from the Energy Information Administration earlier this week, however. The U.S. Department of Energy reported oil inventories fell by 2.6 million barrels during the week ended March 16. Analysts on consensus expected the EIA to report a 3.3 million-barrel build in crude.

A positive spin on oil prices helped energy stocks on the S&P 500 avoid the broader market selloff. While the S&P 500 was little changed around 2 p.m., oil and gas producers, led by Newfield Exploration Co. (NFX) , Anadarko Petroleum Corp. (APC) and ConocoPhillips (COP - Get Report) , were up more than 1% on average. 

Integrated oil majors Exxon Mobil Corp. (XOM - Get Report) and Chevron Corp. (CVX - Get Report) were both climbing near 1% or more, while refiners also played in the green by about 1% on average. 

Oilfield services stocks on the S&P 500 also were averaging a healthy day, despite Baker Hughes and larger competitor Schlumberger Ltd. (SLB - Get Report) being slightly in the red. 

Schlumberger is a holding in Jim Cramer's Action Alerts Plus

Tudor, Pickering, Holt & Co. analysts said in a note earlier this week that it is too early to give up on oilfield services providers despite some weather-related challenges presenting themselves in early 2018. The firm sees Patterson-UTI Energy Inc. (PTEN - Get Report) as the most compelling risk-reward play among mid-cap providers. 

Meanwhile, Seaport Global Securities analyst Mike Urban noted this week after a sit down with oilfield services behemoth Schlumberger that oil producers face a troublesome shortage in so-called frac sand, a type of sand used to prop open wells drilled in U.S. shale deposits across the country. 

One company that seems to have no issues with sand, however, is Diamondback Energy Inc. (FANG - Get Report) , the firm said Thursday. 

"We were pleased to hear that FANG is likely to slither past any potential near-term sand shortages/delays hitting the Permian," SGS wrote.

Among analysts' other top picks this week are Matador Resources Co. (MTDR - Get Report) , Earthstone Energy Inc. (ESTE - Get Report) and RSP Permian Inc. (RSPP) .

"MTDR's stock continues to command a significant premium (28%) to our 19-company mid-cap peer group ... ," Stifel, Nicolaus & Co. analyst Michael Scialla wrote Thursday. "... MTDR has one of the stronger balance sheets in the group, consistently beats consensus estimates, and is widely viewed as a pioneer in the Delaware where it is pushing the vertical and horizontal extents of prolific resource plays."

Earthstone Energy is an undervalued small cap value play in a premier U.S. resource basin, according to KLR Group's Brad Morris. 

"We believe the company's superior growth profile ('18-'20 CAGR of ~32% vs the peer group median of ~7%) and top tier mid cycle capital yield makes ESTE an attractive way to gain small cap energy exposure," Morris wrote in a Thursday note.

And RSP Permian has become a favorite among analysts following some strategic M&A to bolster its Permian Basin position during the latest commodity downturn. 

"With continued execution across its ~91,900 net acres in the core Permian Basin (~50% Midland Basin/~50% Delaware Basin), we believe RSPP is positioned to drive top quartile debt-adjusted production growth in the coming years while reducing leverage," Williams Capital Group's Gabriele Sorbara wrote Monday. "Overall, with its above average debt-adjusted growth profile and concentrated acreage footprints in the core Midland and Delaware Basins, we believe shares should be awarded a premium."