This may not be the best solution.

Assuming the square wave is steady the COUNT command can be used to count the number of pules in a given time period and write that value to a Variable.

After the COUNT is finished check the Variable. If it is something other than the known value when there is no movement have the code goto the routine of your choice.