gold ends higher, breaks string of losses