A trade function is for fine control of trade entry and exit - for details, check out enterLong/Short in the manual. You normally use a trade function, and not a for(open_trades) loop, for exiting a trade under a trade-specific condition. The advantage is that a trade function can react on any tick.

The pointer of the current trade in the for(open_trades) loop is g->tr, so for closing only a particular order, use exitTrade(g->tr,0).