trade EURUSD by another currency with EA

 

hi guys i try to trade  eurusd , by another chart ,the EA is placed over EURCAD and  here i want trade EURUSD but  if i try not  work why ??


//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
int f=10;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   for (int i=0 ;i<=f;i++ ){
   
   int ticketBuy=OrderSend("EURUSD",OP_BUY,0.01,Ask,3,0,0,"By Expert BUY","123456",0,clrGreen);
   
   }
  }
//+------------------------------------------------------------------+
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2021.01.21
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

hi

can you share the errors in "journal" tab?

are you sure the symbol is exactly named "EURUSD" but not "eurusd ", "EURUSD.m"... ?

are you sure your broker minimum lot size for eurusd is 0.01?

is "3" slippage enough in your conditions of trade?

and please modify the magic number to a number but not a string!!

 
int ticketBuy=OrderSend("EURUSD",OP_BUY,0.01,Ask,3,0,0,"By Expert BUY",123456,0,clrGreen);

The common and glaring error  is attempting to place a trade in one symbol using the Ask price of the chart symbol.

 
Keith Watford:

The common and glaring error  is attempting to place a trade in one symbol using the Ask price of the chart symbol.

really nice read!! your right!

 
Issam Kadhi:

hi

can you share the errors in "journal" tab?

are you sure the symbol is exactly named "EURUSD" but not "eurusd ", "EURUSD.m"... ?

are you sure your broker minimum lot size for eurusd is 0.01?

is "3" slippage enough in your conditions of trade?

and please modify the magic number to a number but not a string!!

yes  i am sure  100%  i used  also

SymbolName

is  EURUSD and  yes  accept 0.01 lot size slipage is correct

and  also if i use  bid , not  open a  ordersend

in expert not return error

and is i use   the same script  but  place  EA over EURUSD work  but if  i palce over USDCAD  with EURUSD in order send dont work  is possible execute  also if EURUSD is over another chart ?


 

i find solution eurekaaaaaaa

double vask    = MarketInfo("EURUSD",MODE_ASK);

   int ticketBuy=OrderSend("EURUSD",OP_BUY,0.01,vask,3,0,0,"By Expert BUY",123456,0,clrGreen);
   

thankz  at all

https://www.mql5.com/en/forum/145600



How to place orders on Multiple Symbols?
How to place orders on Multiple Symbols?
  • 2013.06.28
  • www.mql5.com
Hi, I am running an EA on EURUSD. I would like to place orders on other symbols. How can I do it? Thanks in advance. With Regards, Krishna...
 
faustf:

i find solution eurekaaaaaaa


thankz  at all

https://www.mql5.com/en/forum/145600

well to be fair the solution was already given to you above by Keith

Reason: