How to set Order Filling Type?

 
I'm working on an Expert Advisor which sets the filling type on orders according to broker's available types.
I'm using CTrade class for opening positions.

CTrade myTrade;

bool IsFillingTypeAllowed(string symbol,int fill_type) 
{ 
   int filling=(int)SymbolInfoInteger(symbol,SYMBOL_FILLING_MODE); 
   return((filling & fill_type)==fill_type); 
}

int OnInit()
{
   asset = Symbol();
...
}

void OnTick()
{
...

   if (IsFillingTypeAllowed(asset, ORDER_FILLING_RETURN))
   {
      myTrade.SetTypeFilling(ORDER_FILLING_RETURN);
   }
   else if (IsFillingTypeAllowed(asset, ORDER_FILLING_IOC))
   {
      myTrade.SetTypeFilling(ORDER_FILLING_IOC);
   } 
   else if (IsFillingTypeAllowed(asset, ORDER_FILLING_FOK)) 
   {
      myTrade.SetTypeFilling(ORDER_FILLING_FOK);
   }

   PrintFormat("Order Filling Code(%d)", myTrade.RequestTypeFilling());
   PrintFormat("Order Filling Type(%s)", myTrade.RequestTypeFillingDescription());

...

   myTrade.PositionOpen(....);

...

}
Because the brokers(most of them) do not support all filling types, the idea is to find EA's filling types in order to avoid invalid filling messages.
No matter what broker I'm using, the filling is set to FOK(fill or kill) every time.


Am I missing something?
 
Anyone?
 

Wow... 2 years but I would like to contribute to you and others.


You can set the filling using

m_trade.SetTypeFilling(ORDER_FILLING_IOC);        //SYMBOL_FILLING_IOC

just before BUY or SELL.  

Here I can trade some positions (other not and I didn't really understand why).


Regards

Reason: