New! Looking to get my diet fixed and break some habits!

Options
I'm 17 at height 5 ft 9 and have some issues with food - I lost a lot of weight starting when I was 14 and I remember at some point being 9.5 stone and recently my lowest has been 7.5 stone. Last time I weighed myself I was 8st but I've stopped weighing as it messes with my head. I know I must have lost muscle during dieting so I want to turn some of my 'skinny fat' into muscle by getting for and fixing my diet (right now I'm basically living on cereal, and in a restriction-binge cycle binging on high sugar foods usually twice a week). I must be at about 8.5st now and I'm quite doughy and weak so I'd like to firm up.
Currently eating about 1300 - 1800 cals a day and I count cals obsessively and treat 1800 as a maximum which I probably shouldn't do but I really need some advice as I don't know how to get out of this cycle and into a fitness routine.
Anyone got a plan for me to follow or some rough guidelines? That'd be great, thanks!