Spot on Dabba, I thought that too, but then if the OP does not describe exactly what he wants then..... however, If he uses both limits to effectively drive the logic i.e. closed limit initiates open then when it reaches the open initiates the close sequence, if it fails to reach a limit then it will stop ? only other way to keep it going is ignore the limits, count the strokes & also count the limit trues.
So have three counts or even four although that does not quite make sense.
I think the replies so far has given the OP some food for thought though