When a stock is near its 52-week highs and has gained nearly 30% over the past year (while major stock indices have fallen), the temptation for investors to lock in profits is intense.

Campbell Soup (CPB) - Get Campbell Soup Company Report now presents exactly that situation. And investors may be even more itchy to sell after a Morgan Stanley analyst reiterated his bearish stance on the stock.

Image placeholder title

CPB data by YCharts

On the other hand, management at Campbell Soup just raised its earnings guidance for its 2016 fiscal year, which concludes at the end of July. And last month, analysts J.P. Morgan upgraded the stock to neutral from underweight.

And so what should you do? Take your profits or hold your position in the hopes of even more gains? Let's take a closer look at the stock. 

This packaged foods company has had a remarkable run of late. It has beaten Wall Street's expectations in the last three quarters, and in the last reported quarter it topped estimates by a sweet 25%. Campbell Soup plans to report its fiscal second-quarter results on Feb. 25. On average, analysts are predicting adjusted earnings per share of 76 cents, vs. 66 cents a year earlier. But the company's recent full-year earnings guidance suggests it could deliver another surprise next week. The company said its expected 9% to 12% growth in adjusted EPS for the full year, up from previous guidance for growth of 4% to 7%.

General Mills is expected to report a 0.34% EPS drop for the May 2016 year and a 7.34% rise for the year next. For Mondelez International Inc., the Dec. 2016 year is expected to see no growth in terms of EPS but the year next should witness a 15.42% rise, as per analysts.

Campbell has several positives going for it; the iconic Campbells brand is one such solid pillar. Its portfolio includes Pepperidge Farm, Bolthouse Farms, Arnotts, V8, Swanson, Pace, Prego, Plum, Royal Dansk, Kjeldsens and Garden Fresh Gourmet, all of which strengthen its market position.

TheStreet Recommends

Plus, consumer goods output is growing fast (which is good news for companies like Campbell). The guidance lift is possibly partly driven by that enthusiasm.

The company's strategy of saving costs is working well, with Campbell now estimating savings of $300 million (from $250 million previously) by the close of fiscal 2018.

The only real problem with holding Campbell Soup is that you've got to convince yourself that there is the possibility of gains in the stock, when all of Wall Street is betting that the upside is capped. The 12-month median price target (from 11 analysts covering Campbell) is $54. That's 11.3% down from current levels.

If you look at valuations and price/earnings to growth, the numbers suggest that Campbell, which may be sturdy business-wise, is largely overvalued at a five-year expected price-to-earnings (PEG) ratio of 3.84. That's a 50% premium over the industry PEG of 2.58 and 150% more than the S&P 500.

The PEG ratios of similar processed and packaged goods stocks put Campbell's high valuation into context: B&G Foods Inc. (1.50), Flowers Foods Inc. (1.95), ConAgra Foods Inc. (2.71), The J. M. Smucker Co. (2.69) and Tyson Foods Inc. (1.26).

Of course there are companies like Kellogg Co. K (4.52) and General Mills Inc. (3.63) which are better valued than Campbell at present.

From a dividend perspective as well, a two-year track record of growth and a 2.05% yield for Campbell Soup isn't really something that can be deemed as attractive. The likes of PepsiCo with over four decades of dividend growth totally steal the show in this department.

The upshot: Book 50% profits in Campbell and re-invest those gains in other opportunities in the market. A 30%+ gain is handsome and you should take at least a portion of the same off the table.

Are you making the right investment moves for your retirement, or are you blowing it by making all-too-common money mistakes? There are crucial steps that you should be taking now, to build wealth over the long haul. To find out whether you'll have enough money in your later years, download our free report: Your Ultimate Retirement Guide.

This article is commentary by an independent contributor. At the time of publication, the author held no positions in the stocks mentioned.