Invalid Request On OrderSend

To add comments, please log in or register
Nathan Hennigh
34
Nathan Hennigh  

I have been trying to place a sell order through my EA and have run into several issues.

Here is my current code, I get failed market sell 100.00 EURUSD sl: 1.12718 tp: 1.12743 [Invalid request] and retcode of 10013.

I changed my volume to 1000 and then got an invalid volume error, so i changed to .01 and then i got an invalid stops error.

Thanks in advance for any help.

void     placeOrderSell()
   {
      MqlTradeRequest   request;
      MqlTradeResult    result;
      MqlTick           Latest_Price;
      static double     price;
      
      ZeroMemory(result);
      SymbolInfoTick(Symbol() ,Latest_Price);
      price = Latest_Price.bid;
      request.action = TRADE_ACTION_DEAL;
      request.magic = 3;
      request.price = NormalizeDouble(Latest_Price.bid, Digits()); 
      request.type = ORDER_TYPE_SELL;
      request.symbol = Symbol();
      request.volume = 100;
      request.type_filling = ORDER_FILLING_FOK;
      request.price = 0;
      request.tp = + price + .0001;
      request.sl = price - .00015;
      Print("Open Sell Order");
      OrderSend(request, result);
      Print("Result code is " + result.retcode);
   }
Siti Latifah
15813
Siti Latifah  
Nathan Hennigh:

I have been trying to place a sell order through my EA and have run into several issues.

Here is my current code, I get failed market sell 100.00 EURUSD sl: 1.12718 tp: 1.12743 [Invalid request] and retcode of 10013.

I changed my volume to 1000 and then got an invalid volume error, so i changed to .01 and then i got an invalid stops error.

Thanks in advance for any help.

for lots

double lots=0.01;
request.volume = NormalizeDouble(lots,2);


for SL and TP

double SL = 300;

request.sl =NormalizeDouble (price + SL *_Point,_Digits);  //for sell
lippmaje
603
lippmaje  

You also need to zero your request like this:

ZeroMemory(request);

And then you have set the price to 0 before sending the order. Leave it as is (at the bid).

// request.price = 0;
To add comments, please log in or register