You have the same pin as you have for the index working an OEM trigger, that is likely your problem.
Hood
Just found the definite culprit, you have the same pin as you are using for the index set up for the X++ JOG, so everytime the index is seen it will look like a press of a jog X++ button.
When code is running Mach disables all external jog commands so thats why you only see when stopped or in feedhold.
Hood