I'd like to know when an orbit is closed. I know that, to have a closed orbit, there is a ratio that must be a rational number, but I don't know other things..
There's a branch of study called dynamical systems theory that deals with questions like this. The answer is not straightforward, except in a handful of cases. Trajectories can appear to be highly chaotic and yet, when observed for a sufficiently long time, will turn out to be perfectly periodic. The notion of Poincairé recurrence time arises, which suggests that over a long enough time, any orbit must be considered periodic. This, in turn, leads to a debate over whether there is such a thing as an irrational number in a physical system with lower limits to measurable lengths and times.
The straightforward answer to this very broad question is that there isn't a straightforward answer.
To add to KDN's nice answer, there is a theorem called Bertrand's theorem which states that in the case of a particle moving in a central potential, the only potentials that produce stable, closed orbits are the inverse square and radial harmonic oscillator potentials.