OrderSend - Script

 

Hi

 I am using the following command in a script and it is working correct with one of my broker account.  Today I opened a new demo account with another broker but the same script is not sending the order and I am also not getting any error code.  I have checked the options in mt4 Allow DLL and Live trading.  Both the mt4 versions are same 4.00 built 745.  I can't figure out what am I missing. Please help. 

 result = false;
      result = OrderSend("USDJPY",OP_BUY, orderlot-ujlot, MarketInfo("USDJPY", MODE_BID), 5, 0, 0);
      if(result == false)
        {
          Alert("Order USDJPY" , orderlot-ujlot , " failed to BUY. Error:" , GetLastError() );
        }
 
ECN brokers do not allow OrderSend() with sl and tp

So you must OrderModify to set the sl and tp separately

Is your demo an ECN broker ?
 

Hi Agent

 

Thanks,  Actually the script is working fine with an ECN Broker.  The new account I am trying with is not an ECN. where the order has not been executed, and also not throwing an error. 

 
richo:

Hi Agent

 

Thanks,  Actually the script is working fine with an ECN Broker.  The new account I am trying with is not an ECN. where the order has not been executed, and also not throwing an error. 

 

 

use the SRC to post the entire code ?
 
Let me ask this

Does the demo broker allow you to send a sl and tp along with your OrderSend() ?

If they do allow tp and sl,  then the sl and tp of 0 won't place orders and also may not error as far as I know

However, without the rest of the code and knowing this it's hard to tell, but you could try setting a sl and tp just to see.

 
Agent86: ECN brokers do not allow OrderSend() with sl and tp
IIRC that was fixed prior to build 600
 
int ticket;;
      ticket = OrderSend("USDJPY",OP_BUY, orderlot-ujlot, MarketInfo("USDJPY", MODE_ASK), 5, 0, 0);
      if(ticket==-1)
        {
          Alert("Order USDJPY" , orderlot-ujlot , " failed to BUY. Error:" , GetLastError() );
        }
OrderSend does not return a bool. You are getting the error, but your print is not reporting it. See revision above
 

Hi GumRai

 

Thanks a lot, I have rectified and its working fine.   

Reason: