Valency can be thought to be the hands of an atom of an element.
when the valance shell of an atom has electron 1,2,3 then it can loose that amount of electron so its valency will be 1,2 or3. when no. of electron will be 1,2or 3 it will make a cation to complete its octet.
when any atom of element has 5,6or7 electron in its valance shell so it will gain the no. of electron needed to complete its octet. so in this case valency can be found out by--- 8(octet) - no. of electron in valance shell. it will form a anion.
if no. of valance electron is 8 then it will neither gain nor loose electron it will be chemically inactive and that element will be a noble gas.
if valance electron is 4 then it will loose four electron in its to complete its octet.