Gold edges higher to near $5,150 on safe-haven demand