Miscarried

We are actively trying to conceive our fourth child. I was late on my calve, which Is always on time, so we took multiple pregnancy test. We were sooo excited it was positive. We calculated 5 weeks. Unfortunately, the next week I woke up without warning and was bleeding. We went to the ER and it was confirmed. This is the first time this has ever happened. Very saddening... We are still going to try again.. I am just scared now. When is it ok to have sex again and try to conceive after an early miscarriage?