This is unrelated to pending. If you do not want SPX500 trades to affect NAS100 trades, then do not check for ...Total, but for ...Long and ...Short.

You can get the complete status of all trades with a for(...trades) loop, and this way count and check all conditions that you want.