Vitamin D seems to be what has most relieved me getting leg cramps. I finally narrowed it down to that vitamin being the primary helper. More specifically getting my D blood level above 40. I also added vitamin k2 which supposedly helps calcium into the bone, but I don’t know whether the k2 helped with the cramps, the vitamin D was already effective. I also think my low iron contributes to my muscle fatigue and witness, and maybe cramps. I feel stronger when my iron is up in the normal ranges. My doctor recently recommended taking magnesium also, even though my magnesium is in the normal ranges, but I haven’t tried it yet, so I don’t have personal experience with it.
I also am extremely careful not to get the charlie horse in the first place. If I feel it happening, I flex my foot fast and can usually avoid it, but once it really cramps it is almost impossible, it can take a while of agony. Same with my biceps, when I am at my worst, holding my phone to my ear for a few minutes can cause a cramp in the bicep that can put me into tears. I can’t straighten my arm, even after it relaxes a little the muscle still hurts for an hour. I haven’t had that happen in about a year, but it was happening quite often for a while there. The D seems to have helped tremendously.
As a side comment to some of the answers, I don’t believe potassium does anything to help if your electrolytes are always normal. However, you might want to get a blood test done immediately after exercise when the muscle seems most vulnerable. I did that, and honestly it did not show anything, but I thought it was a good suggestion by my doctor. She checked my electrolytes, magnesium, cpk, not sure what else. If you are overhyrdrated or underhydrated it could whack out your electrolytes.
I hope you find relief.
Edit: I forgot to mention keeping my thryoid in line also seems to help. When it is outside of normal my muscles tend to hurt more. I just switched to the natural thyroid med Armour, and so far I feel like it is fantastic! But, too early to really tell.