You have to create a neutral particle, so you need to balance out the charges using coefficients of the lowest ratio possible.
To find the subscripts, you need to balance out the number of negative charges and positive charges so that the total charge equals zero.
For example, say you want to make a compound with lithium and chlorine. Chlorine has a charge of -2 and Li has a charge of +1. So for them to cancel out, you need to have a certain number of Li and a certain number of Cl. The lowest possible for them to cancel out is to have 2 Li and 1 Cl. This is because positive two and negative two cancel each other out.