Hmm, I can absolutely relate to this. Having trouble sleeping 5 days after use is a bit of a problem though, and maybe the mdma exacerbated your situation but it's not the sole cause.
Do you have trouble sleeping properly when you're sober anyway?
Do you exercise? Do you eat healthily? Fried food, drinking any beverage with caffeine in it and eating late at night can all greatly affect your ability to sleep.
So the answer to these questions are vital.
Another thing is your age. Are you young? Younger people can typically handle staying up late at night and are more prone to it. If you look at all of the older people (40 and above), you'll notice that practically speaking, none of them stay up a whole night. That's because they just can't do it. They NEED their sleep. Of course there are exceptions, before anyone points it out, but typically this is the case unless they have full blown insomnia.
I can still do so, but at this point in my life I can tell it is becoming extremely detrimental to my health. I've actually done it too much, and I'm sure my life expectancy will forever be affected from it. The only thing is that I've had this problem long before I ever touched substances, and mdma particularly made this worse. So just quitting mdma isn't going to solve the problem (although weed does the job so well, heh). You either need to find some kind of supplement/substance that works for you, or you need to discover the root cause of your inability to sleep. Since everyone is different, I wouldn't be able to tell you what that root cause is. For reference, mine was simply my biological clock was shitted on and my mind becomes super active and able to work tirelessly beginning around midnight.
But abstinence, exercising, eating healthy and being productive helped tremendously. So much doing makes me sleepy.
Not to mention herb/marijuana is such a life saver! It's literally helping me live longer by avoiding unnecessary all nighters.
I think I realized recently that, a couple years ago, what the doc prescribed me for my insomnia (which was much worse before) were benzos. But my sleeping habits became much better without using it, and not even weed is necessary (more like a 100% guarantee I'll get a good night's worth of sleep). I simply uprooted the root cause.
Discover your own, take action and you'll feel the benefits if you keep at it.