Ok I have a couple questions that may help me understand your situation.
How long has your tank been set up ?
How many gallons is it ?
Bio load, how many fish ?
How many corals ?
What do you feed and how often ?
Two possibilities on the magnesium, first being an inaccurate test or reagents are expired. Second would be pertaining to what supplement you are using for calcium? As some has amounts of magnesium in them so you will be dosing mag with calcium. Most brands just have enough to help maintain magnesium not raise it unless you are dosing in mad amounts.
Did you dose a large amount of magnesium to get your levels to 1500 ppm?
What alkalinity supplement are you using ?
The amount needed to be maintained will depend on the amount lost or consumed daily. BRS has a good calculator to help you put the values in and what type of supplement used and will calculate how many grams of the supplement to add to some RoDi water to dose with.
Start lower than what is recommended and retest after an hour or so to make sure you are not over doing it.
Remember to NOT increase more than 1 dkh per day of alk. 1.4 dkh rise a day is the max but why push it to the limit, leave some room for error.
Your nitrates keep going up even with bio pellets, this leads me to again needing some answers from you about your tank.
Do you have a skimmer, is it rated for the size tank ? Type and size ?
Is the skimmer producing good skimmate daily ?
How often do you do water changes? How many gallons ?
How deep is your sand bed ?
@ how many pounds of live rock ?
How often do you chance the bio pellets ? They may leach nitrates back into the water when they are full or exhausted.
These plus the questions above would help make a better educated decision on what is going on in your reef.
Look forward to seeing the answers to questions a and helping you out !
@Breakthecycle2