TORONTO -- Canada's main stock index inched higher on gains by key commodities sectors despite a dip in crude and gold prices and selloff in technology stocks.

Oil prices started the day higher but reversed course after U.S. President Donald Trump announced the firing of John Bolton, his national security adviser.

Investors feared the departure of the Iran hawk could result in Trump relaxing waivers or sanctions against the Middle Eastern regime, resulting in increased crude output, said Natalie Taylor, a portfolio manager with CIBC.

"It's interesting that energy stocks have remained in positive territory even despite that," she said in an interview.

The energy sector gained three per cent on the day with shares of Canadian Natural Resources, Husky Energy Inc. and Crescent Point Energy Corp. each climbing by more than 3.3 per cent.

The October crude contract was down 45 cents at US$57.40 per barrel and the October natural gas contract was down half a cent at US$2.58 per mmBTU.

The S&P/TSX composite index closed up 42.25 points at 16,537.34.

Materials was also higher despite gold falling below the US$1,500 an ounce threshold for the first time in more than a month.

The December gold contract was down US$11.90 at US$1,499.20 an ounce and the December copper contract was flat at US$2.63 a pound.

"The 1,500 was a key level and the momentum has really shifted in gold equities as we've reached that level," Taylor said.

The heavyweight financials sector was higher led by the Bank of Montreal, while the technology sector dropped the most as shares of Shopify Inc. fell 6.2 per cent.

In New York, the Dow Jones industrial average was up 73.92 points at 26,909.43. The S&P 500 index was up 0.96 of a point at 2,979.39, while the Nasdaq composite was down 3.28 points at 8,084.16.

The Canadian dollar traded for an average of 76.03 cents US, compared with an average of 76.02 cents US on Monday.

"It's fairly non-eventful from a news and headline perspective and just a continuation of some of the shifts in momentum that we've seen basically starting the end of August right before the trade were announced," said Taylor.