Gold gains as soft U.S. housing sales halt greenback's rally