Gold has traded close to $4,000 an ounce in recent weeks after losing 14% in the second quarter, its worst showing since 2013.