@anse33 Square brackets refer to individual array elements. For example, array[1] will return the second element for an array, because the indexing starts at 0.

Now, if there are no open orders, OrdersTotal() will be 0.
This:
[OrdersTotal()-1]
will return value of -1. Arrays don't have negative indexes - its out of array range.

Try adding a trade count filter before the block in question.