You should use two different variables. One for counting how many trades are closed per step and another one modifying the lot size accordingly. That will be far easier than using a loop.