opening orders on multiple instruments from a single EA

 

Hi,

I am currently trying out a pairs trading EA on GBPUSD-EURUSD. The EA is attached to the GBPUSD chart on live trading (not backtesting). I have the following code ...

 if (Condition ...)
   {
      Ticket = OrderSend("GBPUSD", OP_SELL, Lots, Bid, Slippage, Ask+StopLoss*Point, Bid-TakeProfit*Point, "MyEA", Magic_Num, 0, Red);
      if (Ticket < 1)   Print("Order Close failed with error #" + GetLastError());      
 
      Ticket = OrderSend("EURUSD", OP_BUY, Lots, Ask, Slippage, Bid-StopLoss*Point, Ask+TakeProfit*Point, "MyEA", Magic_Num, 0, Blue);
      if (Ticket < 1)   Print("Order Close failed with error #" + GetLastError());
}

The problem is that only GBPUSD orders are being opened. I don't even get an error report for the EURUSD. Is it that EA's can only place orders for the instrument chart that they are attached to?

Thx

 

You are trying to open a Buy order on EURUSD at GBPUSD Ask Price, you need to use MarketInfo to find EURUSD Ask price

Print should be in the Experts tab

 
Fantastic, thx!!