When John Roth thinks back on the oil market of two years ago, a certain calamitous image comes to mind: “I liken it to pushing a freight train off the top of a hill,” says Roth, manager of the $3 billion Fidelity New Millennium Fund. “After a while it starts to really gain momentum, and it takes a lot of money and effort to go the other way.”

Beginning in the summer of 2014, of course, crude prices collapsed much faster than energy producers could hit the brakes on production; some companies kept drilling even as the oil-supply glut worsened, hoping to get the most out of the ground before prices fell further. And today, even though oil has rebounded well off its early 2016 lows to $45 a barrel, energy companies’ balance sheets are still suffering from the hangover. Profits have fallen to such paltry levels that the energy sector, even amid its bear market, is the most expensive in the S&P 500, trading at an average 131 times earnings. Yet some experts say that’s a buying signal. “The short of it is, you’ve got the cycle moving in the right direction,” says Roth, who is overweight in energy. The investor is also encouraged by signs that OPEC and Saudi Arabia are finally considering a freeze that could prop up oil prices. Pipeline operator Williams wmb , one of Roth’s top holdings, could benefit from a resulting revival of U.S. exploration. And a Trump administration is more likely than its predecessor to green-light pipeline expansion projects that Williams could build, Roth says.

If oil prices flatten out or even fall, that won’t hurt Suncor su , which can stay profitable as long as oil stays above $24 a barrel, says Ben Kirby, comanager of the $15.8 billion Thornburg Investment Income Builder Fund. Calgary-based Suncor (better known at the pump as Sunoco) works predominantly in Canada’s oil sands, a unique energy reserve where oil is essentially mined like metal and diamonds (with dump trucks and shovels instead of oil rigs). That costs a lot less than most U.S. energy production. “So every year this company spits out a lot more free cash flow than your typical oil major,” Kirby says. Both Williams and Suncor pay dividend yields of nearly 3%.

fun_recession_cpi_oil

After a five-year bear market in most metal commodities, miners finally had a bull run in 2016, with some stocks’ prices more than doubling off their lows. After the U.S. elections, prices for copper and iron ore, used in building and construction projects, surged amid hopes for increased infrastructure spending. Individual mining stocks tend to be fairly volatile, but investors can get exposure to copper and steel producers with the SPDR S&P Metals and Mining ETF xme .

Gold and gold-mining stocks, whose prices rise amid political uncertainty, advanced in the run-up to the election, then sank again. If the U.S. economy takes off the way stock market investors hope, that won’t be good for gold. But the bearishly inclined may want to take small positions in a gold miner or two. Joe Foster, portfolio manager of the VanEck International Investors Gold Fund, likes Newmont Mining nem , which has cut its costs by about a third in recent years, and B2Gold btg , which bought other companies at bargain prices during the bear market and now is reaping the benefits. Those companies should provide safety in one scenario that Foster foresees: “I think Trump will preside over our next recession.” (For an explanation of why that’s not so far-fetched, click here.)

PICKS:
Williams Cos. wmb
Suncor Energy su
SPDR S&P Metals and Mining xme
Newmont Mining nem
B2Gold btg

This is part of Fortune’s 2017 Investor’s Guide feature, “The 21 Best Stocks to Buy Before Donald Trump Becomes President.” For the rest of the picks (including two funds) in other sectors, click on the links below:

A version of this article appears in the December 15, 2016 issue of Fortune with the headline “Stocks to Keep a Nest Egg Growing.”