The stock market gave up ground on Tuesday, falling in light of some discouraging comments from President Trump relating to the current status of trade negotiations between the U.S. and China. Bullish investors have hoped that tariff disputes might be close to a possible resolution, but the latest move from the White House to encourage a faster finish signaled that progress hasn't been as strong as hoped. Still, some stocks bucked the downward trend in the market. National Oilwell Varco (NOV 0.06%), Trex (TREX -0.92%), and Chegg (CHGG -4.32%) were among the top performers. Here's why they did so well.

Varco gets some energy

Shares of National Oilwell Varco rose 11% after the oil-field services company reported its second-quarter financial results. Varco's numbers looked ugly at first glance, as the company saw minimal revenue growth and posted a massive $5.4 billion loss. However, most of that loss was due to a huge one-time revaluation of key assets. Operationally, Varco did reasonably well, with sales gains in the wellbore and rig technologies segments. Investors were happy to see the energy company held up as well as it did in what's been a tough industry environment for a long time. That boosted share prices, but Varco will still have to rediscover growth opportunities to do well in the long run.

Series of pipelines at an energy terminal.

Image source: National Oilwell Varco.

Trex builds itself up

Home decking specialist Trex saw its stock soar 19% in the wake of its second-quarter earnings release. Sales came in flat, and net income was slightly lower compared to the previous year's quarter. The good news was that Trex saw strong demand for its residential products, and the company managed to boost its production levels during the period to take advantage of that demand. Despite feeling pressure from start-up costs related to new lines of decking products, Trex expects those investments to pay off with stronger results for the remainder of the year. With projections for 25% year-over-year revenue growth in the third quarter, Trex is hitting the summer season on a high note.

Chegg schools the competition

Finally, shares of Chegg finished higher by 9%. The educational specialist said that its subscriber count climbed to 2.2 million, up 30% from year-ago levels. Net revenue during the second quarter of 2019 climbed 26%, and the company said that efforts to expand its total addressable market have been successful. Back-to-school season is a big time for Chegg, and it believes that its academic services have a lot of potential to keep growing for the long haul. With 30 million expert answers and textbook solutions in its library of content, Chegg is changing the face of education, and investors like what they've seen so far from the stock.