NEW YORK ( TheStreet) -- I was talking to Jim Cramer about two oil companies that have reported earnings this week, Anadarko Petroleum ( APC) and BP ( BP). I thought it was interesting to note when good earnings, in the case of Anadarko, might give an investor an opportunity to take some profits, and when bad earnings, as in the case of BP, might yield an opportunity to buy.

Anadarko, which has been a big recommendation of mine for the last several weeks, has been hitting on all cylinders and its latest quarterly results reflected that, with a beat on consensus earnings of 14 cents a share. It has benefited from a rise in domestic oil prices and continued production growth. It seems to be in every one of the hottest areas of U.S. energy production -- the Wattenberg, the Eagle Ford, the Bakken and with natural gas in the Marcellus. Everything seems right for Anadarko.

But much of the value is gone for me with Anadarko trading close to its high of $90 a share today. When I recommended the company, shares were almost 20% lower and now I'm looking to take some profits.

BP, on the other hand, reported badly, missing estimates on earnings by 30 cents a share. The continued overhang from the Gulf of Mexico oil spill in litigation is likely to be a factor for months, if not years. It paid an effective tax rate in the quarter of 45% based upon the rally of the dollar. It got caught in the oil price dive earlier in the year. Their stock is trading at a dismal $41 a share.

But it has gaining public support in their fight against unfounded claims and litigation. They continue to buy back shares - $8 billion worth. Their divestiture efforts in Russia have really begun to bear fruit in cash flow. Finally, its pursuit of deep-water opportunities in the Gulf of Mexico and Brazil are unique in the energy space.

I believe deepwater production will yield the greatest oil opportunities in the next decade. The bottom line is that BP is not being valued in their share price based upon the assets that it owns and the new projects it is pursuing, instead only by the continuing court issues from Deepwater Horizon. I think BP is a screaming buy.

At the time of publication the author positions in APC and BP.

This article was written by an independent contributor, separate from TheStreet's regular news coverage.

Dan Dicker has been a floor trader at the New York Mercantile Exchange with more than 25 years of oil trading experience. He is a licensed commodities trade adviser.

Dan is currently President of MercBloc LLC, a wealth management firm and is the author of "Oil's Endless Bid," published in March of 2011 by John Wiley and Sons.

Dan Dicker has appeared as an energy analyst since 2002 with all the major financial news networks. He has lent his expertise in hundreds of live radio and television broadcasts on CNBC, Bloomberg US and UK and CNNfn.

Dan obtained a bachelor of arts degree from the State University of New York at Stony Brook in 1982.