Request not accepted by the server ?

 
Comments that do not relate to the "BUY SELL orders/deals explanation", have been moved into this topic.
 

Please someone help me!!!

I need to write a script for creating a EA. but the problem is that my requests are not accepted by the server. I don't find the reason! Please guide me. When I compile and start the autotrader I always get a rejected answer from the server.Here is the code:

input int  MagicNumber=1234567;  

myRequest.action=TRADE_ACTION_PENDING;

myRequest.magic=MagicNumber;

myRequest.order=2522322;

myRequest.symbol="mysymbolname";

myRequest.volume=340;

myRequest.price=2996;

myRequest.stoplimit=3200;

myRequest.type=ORDER_TYPE_SELL_LIMIT;

myRequest.type_filling = ORDER_FILLING_RETURN;

myRequest.type_time = ORDER_TIME_DAY;

myRequest.sl=0;

myRequest.deviation=0;

myRequest.tp=0;

MqlTradeCheckResult myResult2;


OrderSend(myRequest,myResult);

if (OrderSend(myRequest,myResult)){

 Alert ("Good");

}else{

Alert ("bad");

};

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 

sd2000sd:

...

myRequest.symbol="mysymbolname";

  • Are you sure this symbol is correct ?
  • What is error code returned by the server ?
 
sd2000sd:

Please someone help me!!!

I need to write a script for creating a EA. but the problem is that my requests are not accepted by the server. I don't find the reason! Please guide me. When I compile and start the autotrader I always get a rejected answer from the server.Here is the code:

myRequest.order=2522322;

myRequest.type_time = ORDER_TIME_DAY;

 

You could try to use ORDER_TIME_GTC instead of ORDER_TIME_DAY...  

Another possible error is the usage of myRequest.order=2522322 ... You might simply comment (//) this entire line of code, once you don't need to specify the order code...

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 
Malacarne:

 

You could try to use ORDER_TIME_GTC instead of ORDER_TIME_DAY...  

Another possible error is the usage of myRequest.order=2522322 ... You might simply comment (//) this entire line of code, once you don't need to specify the order code...

From my experience setting a member not needed for the request type doesn't lead to an error, the will be simply ignored. Same for "myRequest.stoplimit=3200;" which isn't needed for a ORDER_TYPE_SELL_LIMIT.

User have to print the returned value :

}else{

Alert ("bad, error = ", myResult.retcode);

};
Reason: