Invalid Filling type error with FxPro demo account

 
Hi,

I have created an EA which works well for meta quotes demo account. The same EA gives error 10030, invalid filling type, when I use FxPro demo account. I tried using FOK as well as IOC, none of them work.

I am using CTrade standard class library to place order. I checked with FxPro on supported Symbol_Filling_mode. It's IOC.

Here is the code I am using

         
 
     CTrade CT;
      CPositionInfo PI;

      MqlTradeRequest trdReq;
      MqlTradeResult trdResult;


     CT.Request(trdReq);  
 
         trdReq.action = TRADE_ACTION_DEAL;
         trdReq.magic = 9000786;
         trdReq.symbol = Symbol();
         trdReq.volume = lotBuy;
         trdReq.type = ORDER_TYPE_BUY;
         trdReq.type_filling = ORDER_FILLING_IOC;
        
   
      string sb = Symbol();
        bool ordSendRes = CT.Buy(lotBuy,sb);


It will be great if someone can help.

Regards.
 

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


 

dilipapte:

...

I checked with FxPro on supported Symbol_Filling_mode. It's IOC.

How ? where in your code did you check ?

Also it should be like this :

      MqlTradeRequest trdReq={0};
      MqlTradeResult trdResult={0};
 
Alain Verleyen:

How ? where in your code did you check ?

Also it should be like this :


I have not checked it in the code. I contacted FxPro to check what should be order filling type. They suggested IOC. For testing purpose I used SystemInfoInteger function which returns 2.

Surprisingly, this code works perfect with meta quotes demo account. 

 
dilipapte:


I have not checked it in the code. I contacted FxPro to check what should be order filling type. They suggested IOC. For testing purpose I used SystemInfoInteger function which returns 2.

Surprisingly, this code works perfect with meta quotes demo account. 


 

I have added following code in my class.

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


void TradeManager::SetFillingType()
{
   if(IsFillingTypeAllowed(Symbol(),SYMBOL_FILLING_FOK))
     {
      fillType=ORDER_FILLING_FOK;
     }
   else if(IsFillingTypeAllowed(Symbol(),SYMBOL_FILLING_IOC))
     {
      fillType=ORDER_FILLING_IOC;
     }
   else 
     {
      fillType=ORDER_FILLING_RETURN;
     }
}

This code is setting fillType to 1. By the MQL documentation, the fill type 1 is FOK and not IOC. Am I missing anything here?

 
Show your last code used to send a request.
 
Alain Verleyen:

How ? where in your code did you check ?

Also it should be like this :


This is the code to send order

        
         SetFillingType();

         CT.Request(trdReq);   
         trdReq.action          = TRADE_ACTION_DEAL;
         trdReq.magic           = 9000786;
         trdReq.symbol          = Symbol();
         trdReq.volume          = lotBuy;
         trdReq.type            = ORDER_TYPE_BUY;
         trdReq.type_filling    = fillType;
        
   
        string sb = Symbol();
        //bool ordSendRes = OrderSend(trdReq,trdResult);
        bool ordSendRes = CT.Buy(lotBuy,sb);
        

And this is setFillingType Method

void TradeManager::SetFillingType()
{
   if(IsFillingTypeAllowed(Symbol(),SYMBOL_FILLING_FOK))
     {
      fillType=ORDER_FILLING_FOK;
     }
   else if(IsFillingTypeAllowed(Symbol(),SYMBOL_FILLING_IOC))
     {
      fillType=ORDER_FILLING_IOC;
     }
   else 
     {
      fillType=ORDER_FILLING_RETURN;
     }
}

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


This is the code to send order

And this is setFillingType Method

Seems correct but impossible to check as we can't compile this code.
Reason: