The calcium/ magnesium thing is somewhat controversial...they appear to "fight" each other. My md/nd says that we live in a calcium rich/magnesium poor society with our reliance on calcium rich products like cow's milk, ice cream, sour cream, yogurt, etc, etc. And mag is not as easily found in our food sources, while most mag supplementation is not easily absorbed by the body.
Speaking from my own experience, tests show I an mag deficient so you might consider testing to avoid wasting time guessing what you need for your particular body. Turns out mag deficiency is very common. ONLY massive doses of magnesium OROTATE (which is easily assimilated in the body) has helped me with the issues you describe and other issues.