Yeah you should definitely use a loop. And I forgot that you need to reset, so in that case do this:
41 0 DO
0 IOX!
16 TICKS
1 IOX!
16 TICKS
LOOP
A couple of things:
-replace the 41 in 41 0 DO with however many iterations you want. So if the elevator goes up 210 times, it would be 210 0 DO
-16 ticks is .8 seconds, and .8 seconds is the miminum cycle I've found for frame motors. The reason it only goes up halfway/arbitrary amount in your code is because 10 TICKS is sometimes too fast for your client / server. If it happens with the provided code, make it higher(20 TICKS, etc)