You can use COUNTOFLONGSHARES or COUNTOFSHORTSHARES in order to know how much orders/lots/shares/contracts are actually already on market. This way you can limit the quantity of orders of your strategy.
I also have a problem with the strategy were it can short and go long and if there is a long trade in operation it can suddenly sell out in loss and go short.
Possible to tell the program to stay in on short or long untill it hits stop or target.