Unsupported filling mode again

 

I know that this topic has been discussed more than hundred of times.

But still... 

The code is following:

void OnTick()
  {
  int m_magic = 123456;   // Magic Number

   MqlTradeRequest m_request;
   MqlTradeResult m_result;
//-- Clear structures m_request,m_result
   ZeroMemory(m_request);
   ZeroMemory(m_result);
//--- 3. example of buying at the specified symbol with specified SL and TP
   double volume=0.1;         // specify a trade operation volume
   string symbol="EURUSD";    //specify the symbol, for which the operation is performed
   int    digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS); // number of decimal places
   double point=SymbolInfoDouble(symbol,SYMBOL_POINT);         // point
   double bid=SymbolInfoDouble(symbol,SYMBOL_BID);             // current price for closing LONG
   double SL=bid-1000*point;                                   // unnormalized SL value
   SL=NormalizeDouble(SL,digits);                              // normalizing Stop Loss
   double TP=bid+1000*point;                                   // unnormalized TP value
   TP=NormalizeDouble(TP,digits);                              // normalizing Take Profit
//--- receive the current open price for LONG positions
   double open_price=SymbolInfoDouble(symbol,SYMBOL_ASK);
   string comment=StringFormat("Buy %s %G lots at %s, SL=%s TP=%s",
                               symbol,volume,
                               DoubleToString(open_price,digits),
                               DoubleToString(SL,digits),
                               DoubleToString(TP,digits));

//   Check_SYMBOL_ORDER_MODE(symbol);
                            
   ENUM_ORDER_TYPE_FILLING order_type_filling = ORDER_FILLING_IOC;
   ENUM_ORDER_TYPE         order_type = ORDER_TYPE_BUY;
   
   int m_deviation = 1;
   
   if(IsFillingTypeAllowed(symbol,SYMBOL_FILLING_FOK))
     {
      order_type_filling=ORDER_FILLING_FOK;
     }
   else if(IsFillingTypeAllowed(symbol,SYMBOL_FILLING_IOC))
     {
      order_type_filling=ORDER_FILLING_IOC;
     }
   else 
     {
      order_type_filling=ORDER_FILLING_RETURN;
     }
      
//--- setting request
   m_request.action        =TRADE_ACTION_DEAL;
   m_request.symbol        =symbol;
   m_request.magic         =m_magic;
   m_request.volume        =volume;
   m_request.type          =2;
   m_request.price         =bid;
   m_request.sl            =SL;
   m_request.tp            =TP;
   m_request.deviation     =m_deviation;
   m_request.type_filling  =order_type_filling;
   

   
   m_request.comment       =comment;
//--- action and return the result
   bool b = OrderSend(m_request,m_result);
   if(!b)
     {
      //--- failure message
      Print("Buy() method failed. Return code = ",m_result.retcode,
            ". Comment: ",m_result.comment);
     }
   else
     {
      Print("Buy() method executed successfully. Return code = ",m_result.retcode);
     }
  }
  
  bool IsFillingTypeAllowed(string symbol,int fill_type)
  {
//--- Obtain the value of the property that describes allowed filling modes
   long lv;
   bool x = SymbolInfoInteger(symbol, SYMBOL_FILLING_MODE, lv);
//   long vvv;
//   bool y = SymbolInfoInteger(symbol, SYMBOL_ORDER_MODE, vvv);
   int filling =(int)lv;
//--- Return true, if mode fill_type is allowed 
   return((filling & fill_type)==fill_type);
  }

It always returns "Unsupported filling mode" in spite of my attempt to set an appropriate filling type.

I've read many topics before ask.

I'd appreciate any help.

Thanks.
 
ENUM_ORDER_TYPE         order_type = ORDER_TYPE_BUY;

This one is not in your request.

 

That's right, but it doesn't change anything. Just tried...

 

Well you can look at the examples.

All the way below https://www.mql5.com/en/docs/constants/structures/mqltraderequest


Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Interaction between the client terminal and a trade server for executing the order placing operation is performed by using trade requests. The trade request is represented by the special predefined structure of MqlTradeRequest type, which contain all the fields necessary to perform trade deals. The request processing result is represented by...
 

I've acted exactly by the book:

//--- declare and initialize the trade request and result of trade request
   MqlTradeRequest request={0};
   MqlTradeResult  result={0};
//--- parameters of request
   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation
   request.symbol   =Symbol();                              // symbol
   request.volume   =0.1;                                   // volume of 0.1 lot
   request.type     =ORDER_TYPE_BUY;                        // order type
   request.price    =SymbolInfoDouble(Symbol(),SYMBOL_ASK); // price for opening
   request.deviation=5;                                     // allowed deviation from the price
   request.magic    =EXPERT_MAGIC;                          // MagicNumber of the order
//--- send the request
   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code
//--- information about the operation
   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);


... The same result :( ...

the Tester answers:   "failed market buy 0.10 EURUSD [Unsupported filling mode]"


 
https://www.mql5.com/en/search#!keyword=GetFilling&module=mql5_module_forum
MQL5.Community
MQL5.Community
  • www.mql5.com
Searching is based on morphology and is insensitive to case. All letters, no matter of their case, will be processed as lowercase. By default, our search engine shows pages, that...
 
grilikh:

I've acted exactly by the book:

... The same result :( ...

the Tester answers:   "failed market buy 0.10 EURUSD [Unsupported filling mode]"


Are you saying that a textbook example isn't working?

 

Exactly! It isn't.

 

I have just tried the example and you are right it does not open position and returns 100030, so i have notified service desk about the issue.

The first try was on BTC and did not work but then i tried on EURUSD and it did open position...

 

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Особенности языка mql5, тонкости и приёмы работы

fxsaber, 2017.07.11 10:50

// The EA returns fully-formed trading requests (including manual)
#define TOSTRING(A)  #A + " = " + (string)(A) + "\n"
#define TOSTRING2(A) #A + " = " + EnumToString(A) + " (" + (string)(A) + ")\n"

string ToString( const MqlTradeRequest &Request )
{
  return(TOSTRING2(Request.action) + TOSTRING(Request.magic) + TOSTRING(Request.order) +
         TOSTRING(Request.symbol) + TOSTRING(Request.volume) + TOSTRING(Request.price) + 
         TOSTRING(Request.stoplimit) + TOSTRING(Request.sl) +  TOSTRING(Request.tp) + 
         TOSTRING(Request.deviation) + TOSTRING2(Request.type) + TOSTRING2(Request.type_filling) +
         TOSTRING2(Request.type_time) + TOSTRING(Request.expiration) + TOSTRING(Request.comment) +
         TOSTRING(Request.position) + TOSTRING(Request.position_by));
}

void OnTradeTransaction(   const MqlTradeTransaction&, const MqlTradeRequest& Request, const MqlTradeResult& )
{
  if (Request.action)
    Print(ToString(Request));
}

If there is a problem with the same Filling, run this Expert Advisor and create the order you need manually (F9 in the terminal). The generated sales request will be printed by the EA.


Select "Buy by Market". Result:

Request.action = TRADE_ACTION_DEAL (1)
Request.magic = 0
Request.order = 1254116
Request.symbol = BTCUSD
Request.volume = 1.0
Request.price = 0.0
Request.stoplimit = 0.0
Request.sl = 0.0
Request.tp = 0.0
Request.deviation = 0
Request.type = ORDER_TYPE_BUY (0)
Request.type_filling = ORDER_FILLING_IOC (1)
Request.type_time = ORDER_TIME_GTC (0)
Request.expiration = 1970.01.01 00:00:00
Request.comment = 
Request.position = 0
Request.position_by = 0
Try to do the same on your account.
 

I've installed MT4. The same code is working on it comprehensively (w/o 100030). Thanks.

Reason: