I went through a similar process to you with the extreme weight loss & gain, when I was about 18 I went on a hardcore diet & although I never stop eating I was obsessively exercising and got down to about 45 kilos, which was extremely unhealthy for my height. From that point I think the hassling of people to get me to eat coupled with completely losing how to have a healthy relationship with food & how to eat normally I gradually put on nearly 60 kilos
over a couple of years. It was a constant battle in my head but most days would be spent bingeing.
Looking back on those days I was completely anxious, my whole life revolved around food & self-hate for letting myself get to that point. My solution was to go away to south america & travel for 6 months, I just figured I needed to get out of here and hopefully confront some demons. It didn't really work as even being in another place, far away from your normal life, the issues always return.
The turning point for me was learning to love myself, which sounds cliche and its not something you can magically do, it takes a lot of life experience to get through. Now i'm on my way to a healthy life again but am quite aware those demons could revisit me at some point.
I didn't intend this post to be all about me - what i'm trying to say is that absolutely everything in your life has to be in a good state of being to be able to lose the weight. From experience its impossible trying to frantically do something when you aren't happy with yourself. I would try focussing on eating healthily rather than dieting, and not thinking about it too much if that's possible, because that will be your downfall. Try setting small goals for yourself that you would like to achieve as a minimum per week, and see if you can achieve some of them, every little bit helps and you will get through this, I guess its just a journey that you need to go through to learn about yourself (even though it really sucks at the time!!)
sorry for the rambling. all the best. x