If you wrote that function yourself: make sure that it really returns the number of open contracts when the trade is open. -1 would be wrong.

https://zorro-project.com/manual/en/brokerplugin.htm