You could prevent the trigger like this :-
if(event_type==event_sonar && disk_is_moving[my.disk_ID] == 0)

However I am curious how can the counter increase if you have while(mouse_left == 1) { wait(1);}

I think it has to do with your trace function.Is it triggered from mouse_left button ?
Please paste that function too.