When should you announce your pregnant publicly?

My husband and I started my fertility treatment this month. I'm very hopeful that it will work and so is my doctor. I'm being cautiously optimistic but I'm also an obsessive planner so I've already started looking at pregnancy announcements and room decor just for fun and to get ideas for when that time comes. My question is when did you announce it? One girl I knew announced as soon as she got a positive at 4 weeks and miscarried two days later then another girl I knew announced at 4 weeks on thanksgiving day and miscarried 2 days ago at 6 weeks pregnant. I want to wait until I know the gender to announce it on Facebook and do a professional shoot to announce. Is that to late? When did you tell close family? I don't want to wait and then get upset that I didn't tell them but after the last two people I knew miscarried, I also don't want to take the chance of telling them and then something happens and I have to tell everyone that the baby didn't make it. I eat right, exercise, and take everything I'm supposed to so I'm praying that when I get my positive there will be no issues from then on but I know that isn't up to me.