Ok several ways you could do it but likely the easiest would just be to use the switch as the home switch for Z (as you have it set now) and then when you start Mach you press the RefAll button to home the machine. If you dont have home switches on the other axis then Mach will set Machine zero for them where you presently are so really its best to jog the machine fully negative on X and Y before you RefAll.
As the Z will have the switch then the RefAll will make the Z move to the switch and then back off until the switch closes, that will now be the Z set as machine coords zero.
So in the macro a command to go to Machine zero on Z would be all thats needed so
code "G53G0Z0"
would do that. You would also need to set the toolchange to Auto Toolchanger on the general config page.
Hood