Gold swings near 18-week low as U.S. optimism weighs