The simplest way is enumerating all open trades and closing the trades that fulfil the condition, like this:

Code:
for(open_trades) {
   if(TradeAsset == "USD/JPY" and TradeLots == 1)
      exitTrade(ThisTrade);
}