Only one trade at the same time...

 

Hi all,

I have an EA. The EA can run on several currincies. The EA should open only one trade at the same time.

What can I do for that?

Best,

Murat Y.

 
I can write a code for only one trade for only one currency. I want to only one trade while the EA running on several currincies.
 
Use the same magic number and only open a trade if there is not a trade open already with the same magic number
 
bool OrderFind(){
   for(int a=0;a<OrdersTotal();a++){//cycle through open trades
      if(OrderSelect(a,SELECT_BY_POS,MODE_TRADES)){
            if(OrderMagicNumber()==MAGIC){//check for matching magic number
               return(true);
            }//Magic
      }//Select
   }//loop
return(false);
}//OrderFind()

if(!OrderFind()){...Open trade...}
else{...Don't open trade...}
 
I still do not understand. Please help me to understand your writing. Thank you that much.