T.
I don't think sticking your daughter in the 'naughty chair' (as one response went) is the simple solution to such a complicated problem. It sounds like there are two issues, one is physical and one is emotional/mental...but the two could possibly be related.
Coincidentally, my daughter went through some similar issues at the same age (physical aches, nervous picking, and being hard on herself). It was not until she was seven, however, that I really started to find connections. Every child is different, but my daughter's situation may be helpful. She had aches and pains constantly and would get 'stuck' on issues. When you said your daughter had made up that new song, it struck a chord. My daughter was always beating herself up too (even though she was acting out like most kids her age do...most children don't beat themselves up). I realized she is a "thinker" and almost-obsessive about certain/selective thoughts. Being of the age where she was learning so much right vs. wrong (peparing for her First Reconcilliation/First Communion), she was verrrry aware of how she was fitting into the "right" or the "wrong". And if she acted out toward me (I was really the only person she would be that way with), she would then beat herself up about it like she was such a bad kid. She wasn't acting out any more than other kids, and is actually a very sweet good kid, but is more of a thinker/dweller than my other older child.
On top of that, she had a really hard time concentrating in school, which prompted me to get her tested for food sensitivities (was not willing to try medication). She also had a couple of tiny patches of eczema, belly aches, leg pains, etc. Come to find out she was sensitive to wheat, egg and dairy (yikes!!). We took her completely off those foods for about 3 months. Within the first 2 weeks, her belly aches vanished, her eczema went away and she was no longer complaining about leg pain (?). She was less irritable with me and was a happier kid---hard to believe because she has always been really happy. She also seemed to stop obsessing quite so much. We did reintroduce each of the foods after 3 months (one at a time), and she is now able to eat them all again. We do have to eliminate dairy for a couple days here/there if her belly starts hurting again or she 'feels' itchy. But for the most part, those foods affect her differently now. This has also (coincidentally?) been a somewhat better year for her as far as concentrating at school.
She is still a thinker, but I try very hard to teach her (without her knowing it) that she can be more "who cares" (for lack of better description) about most of the things she thinks about. I try SO hard to keep that in mind when I, myself, am obsessing about my 'selective OCD' things.
Let's face it, we all have our own things that really matter to us but that may not matter to other moms/families...and we can all tend to get a little obsessive. I know people who think I am too uptight about the 'germ' thing while they would send their child to play a soccer/bsketball/etc. game with a fever as long as the child felt ok. Yet thse are the same people who are uptight about other things that I could not care less about (houses being immaculate, or their children making it onto a certain team/in certain club, or their children getting straight As, etc). The point is, that we can---as parents--all make things worse for a "thinker" child if we do not show (by example) our kids how to also take things in stride. It sounds like with all the nervous picking habits she has, she is quite a thinker/worrier...my daughter' nail picking faded in the last year.
I am not so sure about leg cracking-food connection? But the best overall advice I could give would be to go to a doctor who is open to testing for food sensitivities/other alternative practices besides the stereotypical tunnel vision most pediatricians have. Also, the fact that she sounds so tiny for her age brings the question of celiac disease (gluten intolerance) to mind. If she is intolerant but still eating it, she is not absorbing any nutrition/not developing properly because it has physically damaged her intestines. Don't flip out at that because it is just a thought, and that can be reversed too if she happens to have it. But again, the point is to talk to a doctor that is "open-minded" about conventional AND alternative analysis/treatments. Let me know if you would happen to like the name of the one we saw in West Bloomfield for my daughter.
Best of luck!