exitLong() closes all open long trades with the same asset and algo, so you need no loop.