Return Code: 10004 - Re-quote on Short/Sell Orders

 

Hello There,

I am not sure that why I am getting a retcode 10004 each time the EA is trying to place a sell order if the particular condition is met. I don't observe the same with buy positions. I even thought of using the deviation of 50 as I trading on EURUSD (5 digits) and applied the same still I see no hope.

Can someone please advise what could be possible wrong here.


Here is the piece of code that is placing the sell orders.


   if((KValue0>80) && (DValue0>80))
     {
      if((KValue0<DValue0) && (KValue1>DValue1))
        {
         if(PositionsTotal()>=4)
           {
            Alert("We already have ",PositionsTotal()," Open Positions. Cannot Place More Positions!!!");
            return;
           }
         Comment("SELL");
         ZeroMemory(mrequest);
         mrequest.action = TRADE_ACTION_DEAL;                                // immediate order execution
         mrequest.price = NormalizeDouble(latest_price.ask,_Digits);          // latest ask price
         mrequest.sl = NormalizeDouble(mrequest.price + STP*_Point,_Digits); // Stop Loss
         mrequest.tp = NormalizeDouble(mrequest.price - TKP*_Point,_Digits); // Take Profit
         mrequest.symbol = _Symbol;                                         // currency pair
         mrequest.volume = Lot;                                            // number of lots to trade
         mrequest.magic = EAMagic;                                        // Order Magic Number
         mrequest.type = ORDER_TYPE_SELL;                                     // Buy Order
         mrequest.type_filling = ORDER_FILLING_FOK;                          // Order execution type
         mrequest.deviation=50;                                               // Deviation from current price

         //--- Send Order
         OrderSend(mrequest,mresult);


Regards,

Mohammad Imran Shamsi

 
Mohammad Imran:

Hello There,

I am not sure that why I am getting a retcode 10004 each time the EA is trying to place a sell order if the particular condition is met. I don't observe the same with buy positions. I even thought of using the deviation of 50 as I trading on EURUSD (5 digits) and applied the same still I see no hope.

Can someone please advise what could be possible wrong here.

Here is the piece of code that is placing the sell orders.

Regards,

Mohammad Imran Shamsi

When opening sell, your preferred price will be compared with the prevailing Bid. So normally, we want to supply Bid when we open sell.

So when you supply Ask, with deviation 50, you need to make sure that your spread is less than 50.

 
         mrequest.price = NormalizeDouble(latest_price.ask,_Digits);          // latest ask price
         mrequest.sl = NormalizeDouble(mrequest.price + STP*_Point,_Digits); // Stop Loss
         mrequest.tp = NormalizeDouble(mrequest.price - TKP*_Point,_Digits); // Take Profit
You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.
  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)