Unsupported filling mode - page 2

 
fxsaber:

Yes.


@fxsaber, does it mean, that different brokers may have different ORDER_FILLING_* policies? Hard to understand. But as I said: I am new here ;) 


 

Correct, see https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_filling 

It depends on the broker which are supported. Can be 1 or more.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Requests to execute trade operations are formalized as orders. Each order has a variety of properties for reading. Information on them can be obtained using functions Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The...
 
Roland Rick:

@fxsaber, does it mean, that different brokers may have different ORDER_FILLING_* policies? Hard to understand. But as I said: I am new here ;) 


It's normal. It depends of the account type, the execution type (market/instant), the order type too (pending or market)...

 
Alain Verleyen:

It's normal. It depends of the account type, the execution type (market/instant), the order type too (pending or market)...


First of all: thanks to all.

@Alain Verleyen, ah, OK. But back to the initial question of this thread. I always assumed, that me, the customer (the trader in this case the EA) decides, how (! which fulfilling policy should be used !) the order has to be placed into market, e.g.

void OnTick()
{
        MqlTradeRequest tradeRequest = {0}; 

        tradeRequest.type_filling = ORDER_FILLING_FOK; 
}

I (resp. the EA) want to decide, if I will sell to the specified amount of order size or not...

Or do I understand something completely wrong? Please see https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Requests to execute trade operations are formalized as orders. Each order has a variety of properties for reading. Information on them can be obtained using functions Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The...
 
Roland Rick: @Alain Verleyen, ah, OK. But back to the initial question of this thread. I always assumed, that me, the customer (the trader in this case the EA) decides, how (! which fulfilling policy should be used !) the order has to be placed into market, e.g.

I (resp. the EA) want to decide, if I will sell to the specified amount of order size or not...

Or do I understand something completely wrong? Please see https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties 

I know it seems quite confusing at first, but maybe a simple analogy might help here. Please don't take any disrespect with this, as I am not trying to dumb it down, just that other users may read the thread too and the analogy might be helpful.

Consider that you are going to a restaurant and when you sit down, they give you a "Menu". On this menu is listed what dishes are available (the broker informs you of what filling modes are available), and then you the customer proceed to choose which dish you want to consume (i.e. of the available filling modes, you choose the one you want to apply). However, the Restaurant can give you different "Menus", depending on where you sit (different symbols), so that dishes can be different.

The same applies here, so you should first use the "SymbolInfoInteger( ... , SYMBOL_FILLING_MODE )" to first obtain information about which filling modes are allowed for a particular symbol (which can be different among Symbols or Accounts or Brokers, etc.)

Once you have the list of available Filling modes, you can then decide which filling mode you want to use in the trade, or if you only want to use a particular Filling mode, you can check to see if it is allowed or not.

Now you can proceed with the order placement, with the appropriate filling mode or not at all if it is not available!

PS! Also remember to consider the following (from the Filling Modes documentation):

In the Request and Instant execution modes the Fill or Kill policy is always used for market orders, and the Return policy is always used for limit orders. In this case, when sending orders using OrderSend or OrderSendAsync, there is no need to specify a fill policy for them.

In the Market and Exchange execution modes the Return policy is always allowed for all the order types. To find out whether the other policies are allowed, use the SYMBOL_FILLING_FOK and SYMBOL_FILLING_IOC properties.

EDIT: One more thing, based on experience and not from the documentation. I have had the "displeasure" of cases of where what is reported as allowed for filling mode does not correspond with reality. Where the function confirms that filling mode "A" is allowed, but when I try to us it, it is rejected. So for these cases, I decided to add an input to the EA, where the user can override the selection of the filling mode to the one that is allowed in practice irrespective of what the Symbol Information is reporting. I know this adds to the confusion, but it is a possibility.
 
Fernando Carreiro:

I know it seems quite confusing at first, but maybe a simple analogy might help here. Please don't take any disrespect with this, as I am not trying to dumb it down, just that other users may read the thread too and the analogy might be helpful.

Consider that you are going to a restaurant and when you sit down, they give you a "Menu". On this menu is listed what dishes are available (the broker informs you of what filling modes are available), and then you the customer proceed to choose which dish you want to consume (i.e. of the available filling modes, you choose the one you want to apply). However, the Restaurant can give you different "Menus", depending on where you sit (different symbols), so that dishes can be different.

The same applies here, so you should first use the "SymbolInfoInteger( ... , SYMBOL_FILLING_MODE )" to first obtain information about which filling modes are allowed for a particular symbol (which can be different among Symbols or Accounts or Brokers, etc.)

Once you have the list of available Filling modes, you can then decide which filling mode you want to use in the trade, or if you only want to use a particular Filling mode, you can check to see if it is allowed or not.

Now you can proceed with the order placement, with the appropriate filling mode or not at all if it is not available!

PS! Also remember to consider the following (from the Filling Modes documentation):

EDIT: One more thing, based on experience and not from the documentation. I have had the "displeasure" of cases of where what is reported as allowed for filling mode does not correspond with reality. Where the function confirms that filling mode "A" is allowed, but when I try to us it, it is rejected. So for these cases, I decided to add an input to the EA, where the user can override the selection of the filling mode to the one that is allowed in practice irrespective of what the Symbol Information is reporting. I know this adds to the confusion, but it is a possibility.

Very helpful analogy, thank you. The situation that you mentioned in your EDIT is happening to me right now with a Demo Account at BDSwiss and with the Symbol EURUSD. It outputs "2" but when I set mrequest.type_filling to that number it still fails. I already tried ORDER_FILLING_FOK, ORDER_FILLING_IOC and ORDER_FILLING_RETURN. Nothing worked so far. Do you have any ideas how to approach that behaviour?

 
René Moll:

Very helpful analogy, thank you. The situation that you mentioned in your EDIT is happening to me right now with a Demo Account at BDSwiss and with the Symbol EURUSD. It outputs "2" but when I set mrequest.type_filling to that number it still fails. I already tried ORDER_FILLING_FOK, ORDER_FILLING_IOC and ORDER_FILLING_RETURN. Nothing worked so far. Do you have any ideas how to approach that behaviour?

I'm stuck in the same situation. I'm trying to close a position from the Python API. Whatever filling mode I use I always get the same error:

2020.12.14 21:12:31.759 Trades '######': failed market buy 0.01 CHFJPY, close #109459760 sell 0.01 CHFJPY 116.807 [Unsupported filling mode]

The account is a live account, no demo.

Did anybody find a solution for this?


 

I am trying to create a seriously basic buy script (so I can use hotkeys) I am on OANDA Japan.


I copied the first script directly from here:

https://www.mql5.com/en/docs/constants/structures/mqltraderequest

Example of the TRADE_ACTION_DEAL trade operation for opening a Buy position:

Example of the TRADE_ACTION_DEAL trade operation for opening a Buy position:

#define EXPERT_MAGIC 123456   // MagicNumber of the expert
//+------------------------------------------------------------------+
//| Opening Buy position                                             |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 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);
  }
//+------------------------------------------------------------------+
This gave me the Error:

10030

TRADE_RETCODE_INVALID_FILL

Invalid order filling type


So I tried all 3 different types of fill mode, all fail the same way, and then I checked the fill mode and use it exactly, still the same error - what gives.

#define EXPERT_MAGIC 123456   // MagicNumber of the expert
//+------------------------------------------------------------------+
//| Opening Buy position                                             |
//+------------------------------------------------------------------+
void OnStart()
  {

// print filling modes
   int filling=(int)SymbolInfoInteger(Symbol(),SYMBOL_FILLING_MODE);
   Print("Filling mode ", filling);
//--- 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
   request.type_filling =filling;                          // Oanda needs this
//--- 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);
  }
//+------------------------------------------------------------------+
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Trade Request Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
use this 
enum ENUM_FILLING_MODE
  {
   FOK=0,IOC=1,RETURN=2
  };

input ENUM_FILLING_MODE YourBrokerFillingMode = FOK; //Your Broker Filling Mode 
int Fmode = YourBrokerFillingMode;



//OnTick()
request.type = ORDER_TYPE_BUY;
request.action = TRADE_ACTION_DEAL;
request.symbol = Symbol();
request.volume =Volume;
request.sl = SL;
request.tp = TP;
request.deviation = Order_Deviation;
request.type_filling = Fmode;

request.comment = "www.vixibot.com ";
request.magic = MagicNumber;
        
 
René Moll #:

Very helpful analogy, thank you. The situation that you mentioned in your EDIT is happening to me right now with a Demo Account at BDSwiss and with the Symbol EURUSD. It outputs "2" but when I set mrequest.type_filling to that number it still fails. I already tried ORDER_FILLING_FOK, ORDER_FILLING_IOC and ORDER_FILLING_RETURN. Nothing worked so far. Do you have any ideas how to approach that behaviour?

I wonder if this could be a mistake in the documentation.

When it outputs 2 it is really FoK. 1 is IoC and 0 Return. I would need to check various brokers to see if this is consistent.

EDIT: What I mean to say is that if it outputs 2, you need to set it to 1.

Reason: