OrderSend problem

 
I saw this code in the MQL4 documentation:

  ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
  if(ticket<0)
  {
    Print("OrderSend failed with error #",GetLastError());
    return(0);
  }

and I used it in my expert but it seems that this code opens orders in the backtest but opens no orders in live trading. My question is whether this code only sets the value for the "ticket" variable or it opens the trade as well.

Thanks a lot.

Jan
 
It may be that the  "allow live trading" option is not checked. On active chart, press F7, then click common tab, then check "allow live trading" box, then click OK.
 

OrderSend () is a feature that commits trading operations and returns in terms of this operation is over. If the return values <0 it is a mistake opening position.

If you are having difficulties, I am ready to help you, we have MQL courses, and we write custom. Please ...

 
Thanks for your replies, guys. I'm not new to mql4, autotrading is allowed and now that I changed

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
to

OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
the orders are open in forward test. What confuses me is the fact, that with the previous version of the code they were opened in a backtest but not in live trading. To ask again, do you think the line

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
opens the order?

Jan
 
janklimo:
the orders are open in forward test. What confuses me is the fact, that with the previous version of the code they were opened in a backtest but not in live trading. To ask again, do you think the line

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
opens the order?

Jan
Yes it does. Have you tried to Print the GetLastError() after that OrderSend?