Recently had a miscarriage

I recently had a miscarriage and I was wondering when it would be safe to ttc again. And if I do have sex would I get pregnant before I ovulate again?