Back pain, cramps and spotting- miscarriage?

Di
I'm 4-5 weeks pregnant and I've been spotting for more than a week. It has been mostly light and dark brown blood, but it was bright red a couple of times. 
When the blood was red it was accompanied by really strong cramps and intense lower back pain. But after a while it stopped... And it was back to brown spotting.
I don't get it. I think I'm having a miscarriage but then it stops. What's going on?? 
UPDATE: I got an ultrasound done and they  couldn't find the baby in the uterus.... It's likely to be an ectopic pregnancy.

Glow Resources

Let’s Glow

Glow is here for you on your path to pregnancy

Glow helps you navigate your fertility journey with smart tools, personalized insights, and guidance from medical experts who understand what matters most.

25+ million

Users

4.8 stars

200k+ app ratings

20+

Medical advisors