You probably have the firmware overrides enabled. That means that you have told the software to override your firmware settings. That is why things are getting cleared out, because the stock firmware settings do not include your macro commands.
So there are 2 easy options
1) Click "Edit Process Settings", go to G-Code tab, and disable the "Update firmware configuration" option. This way you won't override your firmware settings anymore.
2) Go to Tools > Firmware Configuration, enter the custom macros that you want, and then click Export at the top to save those settings as a new name. Then go back to "Edit Process Settings", G-Code tab, and leave the "Update firmware configuration" option enabled, but change the "Firmware type" to the name of the new settings you just exported.
If you're interested, you can read more here:
viewtopic.php?f=9&t=2833&p=13286#p11941