TradeIsOpen is invalid until you specify a trade.

Perhaps you should be checking one of the trade statistics instead.
https://zorro-project.com/manual/en/winloss.htm