Market orders always fail because of error #4756 [Unsupported filling mode]

 

Hello guys,

I plot a line in my chart, called "sl". Then I execute my code and I always receive this [Unsupported filling mode] error #4756.

I use almost the same code for my pending orders and they work. But where is the difference between a market order and a pending order regarding the filling mode??

This is my code, any help very appreciated!

double entry;
   double tp;
   double sl=ObjectGetDouble(0,"sl",OBJPROP_PRICE,0);
   ENUM_ORDER_TYPE orderType=-1;
   if (iClose(_Symbol,PERIOD_CURRENT,0)>sl) {
      entry=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
      tp=entry+3*(entry-sl);
      orderType=ORDER_TYPE_BUY;
   }
   else if (iClose(_Symbol,PERIOD_CURRENT,0)<sl) {
      entry=SymbolInfoDouble(_Symbol,SYMBOL_BID);
      tp=entry-3*(sl-entry);
      orderType=ORDER_TYPE_SELL;
   }
   else return;
   if (orderType==-1) return;
   MqlTradeRequest tradeRequest={}; 
   tradeRequest.action=TRADE_ACTION_DEAL;             // setting a market order 
   tradeRequest.symbol=_Symbol;                       // symbol 
   tradeRequest.volume=0.01;                          // volume 
   tradeRequest.sl=sl;                                // Stop Loss
   tradeRequest.tp=tp;                                // Take Profit      
   tradeRequest.type=orderType;                       // order type 
   tradeRequest.price=entry;                          // open price
   tradeRequest.deviation=5;
   MqlTradeResult tradeResult={0}; 
   if (!OrderSend(tradeRequest,tradeResult)) {
      Alert("OrderSend error #"+(string)GetLastError());
      return;
   }
   uint returncode=tradeResult.retcode;
   if (returncode!=TRADE_RETCODE_PLACED && returncode!=TRADE_RETCODE_DONE) Alert("retcode #"+(string)returncode);
 
Have you checked the differences of the prices of your orders: Buy,Sell,Ask,Bid,Sl,TP? Check them with the debugger (hist. quotes)
 

I found a solution for the problem in a posting from 2017. I added this line:

tradeRequest.type_filling=ORDER_FILLING_IOC;

Now it works.

 
Marbo #:

I found a solution for the problem in a posting from 2017. I added this line:

Now it works.

Works for me too
 
Marbo #:

I found a solution for the problem in a posting from 2017. I added this line:

Now it works.

Me too

finally, it works