request for some simple code ?

 
I have been fooling around with this ea system for a while and found its only flaw i can see is it will enter into too many trades at once. so i was wondering if i could get some code for it to only open one position at a time. do not open trade until other trade is closed. any help would be greatly appreciated.
 

Why not have read of https://book.mql4.com/trading/index Programming of Trade Operations - what you need is there.


Perhaps firstly read up on

int OrdersTotal( )


Then having understood this see how it fits into Programming of Trade Operations


hth