gold ends higher, but still posts a loss for the week