Cant open sellLimit Order



I have no ideas anymore what might be wrong with my code. I try to open a SELL LIMIT order but the terminal just says "invalid order", Error code 10035.

Here is the core fragment:

int OnInit()
   const string  symbol = "EURUSD";
   datetime exp_time =TimeCurrent()+9923*60*60;
   const string comment = "TEST";
   bool res_process;
   ctrade.SellLimit(0.01, symbol, 1.3, 1.9, 1.0,   ORDER_TIME_SPECIFIED, exp_time, comment);
   if (!res_process) //if placing failed 
      Print("Failed submitting the order");
      int res_code=ctrade.ResultRetcode();
      string out=" MT5 err code:"+res_code+", "+ctrade.ResultRetcodeDescription();

The output is

I also attached the full mq5 file.

Thank you very much for your help!

I am out of ideas. :(

Update: ok, I see the variable res_process was not assigned. But the error is there anyway. See the first line in the screenshot, which is the direct output of CTrader.

Test.mq5  3 kb

solved. My bad (of course).

The order of the arguments was wrong. (vol, price, symbol, sl, tp) would be correct.

Why would you make an EA to place limit orders? I mean is not like an EA cannot wait for right moment to open a market order ?! 😳
There is no need to create pending orders in code.
  1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
  2. Don't worry about it unless you're scalping M1 or trading news.
  3. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.