Use the for(open_trades) loop, and compare the TradeAsset string - exit the trade when the asset is the currency that you want to close. Check out the example:

http://manual.3dgamestudio.net/fortrades.htm