Hi Pork,
To answer your specific question, for(open_trades) loops through all Pending and Open trades. The Pending ones won't have a TradePriceOpen yet (use TradeIsOpen to bypass them), but the Open ones will.
Re. the crash, as jcl says it's pretty hard to debug a script without seeing all of it. If you don't want to post it follow the debug advice and narrow it down to what's causing the crash.
HTH.