the charge of the ion depends on whether the element it metal or non metal and if its metal it has a positive charge, if its non metal it has a negative charge. the amount of ions depends on the elements group number. for e.g magnesium is a metal in group 2 and so it has a 2+ charge because its a metal and is in group two