It's easy to invest in popular stocks. It's a lot harder to be first to spot a change in the way investors are thinking about entire industries and to buy shares of beaten-down companies. Over the long run, though, having the courage to buck the trend can mean the difference between being a good investor and a great one.

Early this week, stock market investors celebrated the news that another promising coronavirus vaccine candidate could be available soon. That sent major market benchmarks flying. However, it did even more good for one area of the market that was getting crushed even before COVID-19. Finally, some investors are seeing signs of life in an area many had left for dead.

Several oil wells under a setting sun.

Image source: Getty Images.

Oil stocks are lighting up

The energy markets haven't cooperated with investors for years. Now there are some signs that investor sentiment about companies in the oil and gas industry might finally be starting to improve.

Back in 2014, oil was above $100 per barrel. Then the emergence of plentiful supplies from shale oil plays massively shifted the market, sending prices down sharply. That weakened the political strength of oil-producing countries that rely on revenue from crude sales to drive their local economies. In the years since, damaged relationships between those countries have hampered efforts to control production and get the supply-demand equation back into balance. The COVID-19 pandemic only worsened industry conditions by drying up demand temporarily.

Now, though, positive news about coronavirus vaccines is leading value investors to seek out bargains in energy. You can see the influence of value hunters across the oil and gas spectrum from Monday's price action:

  • Major oil producers are gaining traction for the first time in a while, with 6% moves for ExxonMobil (NYSE:XOM) and Royal Dutch Shell (NYSE:RDS.A) (NYSE:RDS.B) and a 5% rise in BP (NYSE:BP).
  • Oil services companies rose in concert with their exploration and production peers. Schlumberger (NYSE:SLB) led the way higher, with gains of 12%.
  • Refining operations are also picking up steam. Marathon Petroleum (NYSE:MPC) added to recent gains with a 9% rise Monday, while Phillips 66 (NYSE:PSX) rose 7%.
  • Midstream transportation and storage plays also did well, including Plains All American Pipeline LP (NASDAQ:PAA), up 7%, and Western Midstream Partners (NYSE:WES) with a 9% rise.

Can it last?

Energy has been in a downward spiral for a long time, so even a whiff of optimism is welcome news. But it'll take sustained increases in oil prices to help many companies. A lot more than a modest rise in crude prices to the $41 to $42 per barrel range will be necessary to turn the tide.

Nevertheless, as we've seen with travel stocks, beaten-down sectors of the stock market can mount powerful rallies. If energy markets can sustain and build on their recent gains, oil and gas stocks could still have a lot further to climb.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.