OverExpose Currency

 

Context: I am trading on 28 different currency pairs

I am trying to create a function where you cant buy or sell two of the same currency at the same time. E.g. buy eur/usd and buy eur/jpy not possible because eur is overexposed. 

Does the code work?

void OverExposureCurrencyPairs(){
   string buypair;
   string sellpair;
   string currentBase;
   string currentQuote;
   for(int Counter = 0; Counter <= OrdersTotal()-1; Counter++)
   {
      OrderSelect(Counter,SELECT_BY_POS);
      //check if trading pool order is buy or sell
      if(OrderType() == 0){//buy
         buypair = SymbolInfoString(OrderSymbol(),SYMBOL_CURRENCY_BASE);
         sellpair = SymbolInfoString(OrderSymbol(),SYMBOL_CURRENCY_PROFIT);
      
      }else if(OrderType() == 1){//sell
         buypair = SymbolInfoString(OrderSymbol(),SYMBOL_CURRENCY_PROFIT);
         sellpair = SymbolInfoString(OrderSymbol(),SYMBOL_CURRENCY_BASE);
         
      }
      currentBase = SymbolInfoString(Symbol(),SYMBOL_CURRENCY_BASE);
      currentQuote = SymbolInfoString(Symbol(),SYMBOL_CURRENCY_PROFIT);
   
      if(currentBase == buypair || currentQuote == sellpair){ //Check to see if I will be overexpose if I buy current pair
         ExposeBuy = True;
      }
      if(currentBase == sellpair || currentQuote == buypair){
         ExposeSell = True;
      }
   }
   
}
forex news - Trading blogs and financial markets analysis
forex news - Trading blogs and financial markets analysis
  • www.mql5.com
Forex – foreign exchange market, or currency market – is the market where one currency is traded for another. Open 24-hours a day from Sunday evening through to Friday night, it is the world's most
Reason: