why this ordersend error happen?

 
void start()
  { 
   string sym="EURUSD";
   OrderSend(sym,OP_BUY,1,Ask,3,0,0,"");
  }
        

when I attach this code to "GBPUSD" chart, it said Ordersend error 4016, Unknown symbol name EURUSD for Ordersend function.

But when I run this code on "EURUSD" Chart, it is fine. WHY?

How can I use a diiferent symbol from the one attached for OrderSend function? Thanks

 

Two possibilities . . .

How can you place a Buy order for EURUSD at the Ask price of GBPUSD ? you need to use MarketInfo and MODE_ASK

Are you 100% sure that "EURUSD" is the correct symbol name ?

 
RaptorUK:

Two possibilities . . .

How can you place a Buy order for EURUSD at the Ask price of GBPUSD ? you need to use MarketInfo and MODE_ASK

Are you 100% sure that "EURUSD" is the correct symbol name ?


thanks for reply, I did use MarketInfo() for my code. And I quite sure that is correct symbol name, becaue it can be used in MarketInfo().
 
Pain:

thanks for reply, I did use MarketInfo() for my code. And I quite sure that is correct symbol name, becaue it can be used in MarketInfo().
 
Print out the error code so you find out WHY!
int ticket = OrderSend(...)
if (ticket < 0) Alert("OrderSend Failed: ", GetLastError());
Reason: