After a terrible 2018, the energy sector is showing signs of life this January. Beaten-down shares of oil and gas companies have climbed on hopes that the energy markets will rebound throughout 2019. In addition, two ETFs that are designed to track the prices of crude oil and natural gas through futures contracts are among the top performers in the new year.

For investors who've tracked the performance of United States Oil Fund (USO 2.70%) and United States Natural Gas Fund (UNG 5.43%) over the years, it's surprising to see the two ETFs near the top of the performance list for a change. However, a shift in the market environment in energy futures has helped give these funds a much-needed boost -- and that trend could continue well into 2019 and beyond.

USO Chart

USO data by YCharts.

How these energy ETFs work

United States Oil and United States Natural Gas both get their exposure to energy prices by using futures contracts. That prevents the funds from having to take physical possession of thousands of barrels of crude oil or a large amount of natural gas, as well as bearing the storage costs involved in working with the commodity itself.

Specifically, the ETFs focus on futures that have the nearest available expiration date. That gives them substantially similar exposure to the changes in spot prices for their respective markets. But in order to avoid getting stuck with having to take delivery of the commodity, the ETFs regularly close out their futures contracts before they expire, replacing them with contracts that expire the following month. That process takes place over a four-day period each month, allowing the fund managers to make the transition in an orderly fashion without being as vulnerable to institutional investors seeking to take advantage of the funds.

Four oil wells with pumps on a hazy day.

Image source: Getty Images.

Steady declines from contango

The problem with this strategy is that over the long run, the way that the futures markets are typically positioned leads to erosion in the ETFs' value over time. That's because most of the time, oil futures are priced so that contracts further in the future are more expensive than contracts closer to expiration. That's known as contango, and it means that when each ETF sells off the near-term contract and replaces it with the next-month contract, it typically has to pay a little extra -- even though the spot price doesn't change at all.

From month to month, those price differences can be very small, but over time, they add up, as you can see below from their price performance over the past 10 years.

USO Chart

USO data by YCharts.

These results might be surprising to many investors, given that back in early 2009, crude oil prices were at around $40 per barrel, about 20% less than their current level near $50. Meanwhile, natural gas has suffered declines, but the fall from about $7.50 to $4 works out to less than a 50% drop -- far less than the 95% loss for fund shareholders.

Why things are looking up for these ETFs

But lately, the usual relationship across futures contracts with different expirations has changed. Now, futures markets are charging higher prices for near-term contracts than for contracts months and years into the future. Rather than contango, this reflects what's called backwardation.

If that state persists, it should help the United States Oil and Natural Gas ETFs. Each month, the funds will replace a higher-priced expiring contract with a lower-priced one for the following month. That'll produce a small incremental benefit even if spot prices don't change.

Keep an eye on energy futures

Before you bet the farm on these two ETFs, though, bear in mind that brief periods of backwardation have happened before. They typically reverse themselves to the more normal state of contango before too long, and when that happens, the tailwinds that help performance return to the headwinds that have been so devastating to long-term investors in these funds.

Nevertheless, for those who think further gains in the energy markets are likely, United States Oil and United States Natural Gas have something going for them that they don't usually have. As long as contango stays away, using these ETFs will have the potential to add an extra benefit for shareholders.

Check out all our earnings call transcripts.