This is the correct code to enumerate pending trades:
for(last_trades) if (TradeIsPending) ...
A trade can be either pending, open, or closed. So always use an if(...) condition to get the trades that you want. If a trade is neither, it's no valid trade.
And can you please post these questions to another thread? This one is about the new release.