How to have only one open trade at a time? - page 2

 
JIHUN NAM #:

Mate,  I am using own EA on multiple symbols...  ex)  GBPUSD, EURUSD, USDJPY  etc..

How can I open only one trade  ??

for example,

If my ea open trade on GBPUSD,   stop open other multiple symbols  until close the previous order(GBPUSD)

Hi

You should use the code that was proposed earlier in this thread, just check if there are any opened orders on this symbol and open new trade only if there are no trades, you can use this code before the function to open the trades:

int Magic = 1234;
int count=0;

 

   for(int i=0;i<OrdersTotal();i++) {

    if(OrderSelect(i,SELECT_BY_POS)) {

     if(OrderMagicNumber()==Magic) {

      if(OrderSymbol()==Symbol()) {

        count++;

       }

      }

     }

    }

 

if(count==0) {

      //your functions to open trades here

 

}

Best Regards