open positions in multiple symbols

 

Hello everyone, I am trying to write an expert advisor that is able to open positions in several currency pairs but when it detects a signal in a currency pair, it opens a position in all the symbols in which it is enabled, I want it to be able to recognize the symbol of where does the signal come from and open a single position in that same symbol


void OnTick() {
double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);

double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);

double RSIArray[];

ArraySetAsSeries(RSIArray,true);

int RSIDefinition = iRSI(_Symbol,_Period,14,PRICE_CLOSE);

CopyBuffer(RSIDefinition,0,0,3,RSIArray);

double RSIValue=NormalizeDouble(RSIArray[0],2);

bool C1;
 bool C2;

bool CA;
 bool CB;

string simbolo = Symbol();
Comment(simbolo);




    //--limitador de ordenes 
 
     if  (!IsPositionExists("EURUSD" ) )
   
     {  
CA=true;
     }
   else
     {
      return;
     }
     //--
     
          if  (!IsPositionExists("USDJPY") )
   
     {  
CB=true;
     }
   else
     {
      return;
     }
     
     //--
     if (RSIValue>70) 
    C1=true;
     Print("signal eurusd");
       if (RSIValue<30) 
    C2=true;
      Print("signal usdjpy");  
      if ((C1==true) && (CA==true))
    OpenBuyOrder();


     if ((C1==true) && (CB==true))
    OpenBuyOrderB();
    
    int error = GetLastError();
    Print(error);
    } 



   //--area de order send
   

  


  //--,Ask-100*_Point,Ask+350*_Point

bool IsPositionExists(const string symbol)
  {
   for(int i=PositionsTotal()-1; i>=0; i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==symbol)
            return(true);
//---
   return(false);
  
  
  }
  
void OpenBuyOrder () {
 MqlTradeRequest request={};
 ZeroMemory(request);
   request.action=TRADE_ACTION_DEAL;
   request.magic=123456;            
   request.symbol="EURUSD";               
   request.volume=0.01;                        
   request.sl=0;                                
   request.tp=0;                              
   request.type=ORDER_TYPE_BUY;              
   request.price = SymbolInfoDouble("EURUSD",SYMBOL_ASK);
   request.deviation = 50;
     request.type_filling = ORDER_FILLING_IOC;
   MqlTradeResult result={};
   OrderSend(request,result); 

}


void OpenBuyOrderB () {
 MqlTradeRequest request={};
 ZeroMemory(request);
   request.action=TRADE_ACTION_DEAL;
   request.magic=123455;            
   request.symbol="USDJPY";               
   request.volume=0.01;                        
   request.sl=0;                                
   request.tp=0;                              
   request.type=ORDER_TYPE_SELL;              
   request.price = SymbolInfoDouble("USDJPY",SYMBOL_BID);
   request.deviation = 50;
     request.type_filling = ORDER_FILLING_IOC;
   MqlTradeResult result={};
   OrderSend(request,result); 
}
 
You will find lot's of code and suggestion if you simply search here for 'multi currency': https://www.mql5.com/en/search#!keyword=multi%20currency
 
Carl Schreiber #:
You will find lot's of code and suggestion if you simply search here for 'multi currency': https://www.mql5.com/en/search#!keyword=multi%20currency
Thank you is exactly what I was looking for