Problem with coding

 

I tried for days now to include a code in the uploaded EA.

The EA uses a TP by now and opens Position based on a Martingale System. I want to replace the original TP with the following idea:

The EA close all orders if he has at least open min. 10 Trades AND is in a hedged Situation (min. 5 Sell and 5 Buy).


I Tried several ideas for counting OP_BUY and OP_SELL but i cant get anything to work. It would be fine if some experienced coder could ad it to the EA.

Files: