Awesome EA with one problem. need help?

 
I created an ea that is doing really good except for one thing. Sometime it executes trades at the same order price as a current open trade. I have come up with a way to fix it, but can seem to find a way to code it correctly. How I would like the logic of the coding to execute is: if ask price is higher than current open position(s) price by 10 pips execute short position or bid price is higher than current open position(s) price by 10 pips execute long position. I can NOT find the coding for open position price. I need some help.
 
how many open positions max?
Reason: