When it comes to investing, heuristic ideas like never selling a stock or never buying a particular industry aren't great practice. At some point, even the best stocks can become overvalued, and the stocks you want to avoid like the plague may be a good buy at the right price. Unfortunately, though, we can't all live by the code of everything for sale and be ready to buy anything.

With this in mind, I have a confession. There are two kinds of stocks that I don't think I will ever buy: independent oil and gas producers and gold miners. Here's why these two particular parts of the energy and natural resources industries are stocks I can't ever see myself owning over the long term.

refusing money

Image source: Getty Images.

Oil and gas producers

For as much time as I spend reading news, financial reports, and company presentations in the oil and gas industries, I still can't quite convince myself that buying exploration and production companies is a good idea for long-term investments that compound wealth over time. 

Don't get me wrong: Having exploration and production assets isn't a bad thing. Integrated oil and gas companies with assets in production, refining, chemical manufacturing, and marketing assets can make great long-term investments. What separates integrated oil and gas companies from those that deal exclusively in the exploration and production side of the business is diversity. Exploration and production is a sound investment under one market condition: rising or higher oil prices.

Yes, the definition of higher oil prices can vary from company to company based on how much it costs to pull a barrel of oil out of the ground. However, there are going to be periods of time when almost no barrel of oil is economical at market prices because, well, that's what oil prices do. When you couple production assets with other assets that benefit from declining or low oil price environments such as refining and chemical production, however, you get a business that will naturally offset each other and provide a steadier stream of earnings and cash flow.

Having that cash flow in any market condition is incredibly important because exploration and production needs constant capital to keep it going. Oil reservoirs don't care what oil prices are; they will produce and deplete and new sources need to be tapped. If producers need to do this in low oil price environments, their financials suffer immensely. 

Money can be made in the exploration and production game, but it involves timing the market cycles just right. Since I -- and let's be real, no one -- can time the market just right, I'm staying away. 

Gold miners

Many of the problems I have with gold miners are the same reasons I can't get behind investing in oil and gas producers: They are wholly reliant on one market condition for favorable results, and they require constant capital investments no matter the market environment to maintain production. 

Of course, some gold miners are better than others. Those that can produce at much lower all-in sustaining costs are more likely to do well because their financial statements can handle lower gold prices, and investors have a higher margin for error with these companies. 

One thing that also makes gold mining even more troublesome is that, historically, they have been terrible capital allocators. Over the past 20 years, only a couple companies have been able to produce a return on capital invested more than 10%, and those periods of performance have lasted no more than a year. 

I get it: Gold and gold miners are more of a natural hedge against the broader economy as investors flee to gold when economic times are tough. If you are looking to make a multidecade investment, though, even the largest and most profitable gold miner -- Barrick Gold -- hasn't been able to produce a desirable long-term return. 

ABX Total Return Price Chart

ABX Total Return Price data by YCharts.

Like oil and gas producers, I'm sure there are plenty of people out there who will make money from gold miners by timing the market just right. The chances of nailing when to get in and out of these stocks on a consistent basis, however, is impossible and, to me, not worth a spot in my portfolio.