FxPro EA test [Unsupported filling mode].

 

Hi,

I have coded a basic MT5 EA which is using the CTrade class to manage trades.

I am currently testing this EA on FxPro MT5.

When I open a trade using the ORDER_FILLING_IOC filling method, it is working fine with trade.PositionOpen.

Now When I use the CTrade class with trade.PositionClose and any of the ENUM_ORDER_TYPE_FILLING I always have an error message: [Unsupported filling mode].

The SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE) return 2 which mean SYMBOL_FILLING_IOC so I have tested both SYMBOL_FILLING_IOC and SYMBOL_FILLING_FOK and same filling issue.

The SymbolInfoInteger(_Symbol,SYMBOL_TRADE_EXEMODE) return 2 which mean if I am correct SYMBOL_TRADE_EXECUTION_MARKET.

Any help to understand the issue would be appreciated as I have tested all possibilities and I still have this issue.


PS: At the moment I am testing the netting mode.

Regards,

G

 

 

PS: With my EA, if for example my first trade is a buy of 0.01 volume, if I try with the EA to open a sell with the same volume of 0.01 then the first trade is closed. It makes sense with MT5 netting mode.

But I thought that the CTrade class would handle if MT5 is in hedging or netting mode and adapt the trade closure accordingly.

Also, considering that only the ORDER_FILLING_IOC filling mode is working, what if the requested volume to close the trade is not available … I presume I would have to run a loop until the trades got closed?

Any feedback / help about how you handle that would be greatly appreciated.

Regards,

G

 
You should show your code. When the execution mode is MARKET or EXCHANGE you should be able to use ORDER_FILLING_RETURN.
 
gringoh:


The SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE) return 2 which mean SYMBOL_FILLING_IOC so I have tested both SYMBOL_FILLING_IOC and SYMBOL_FILLING_FOK and same filling issue.


 

It's not true, because 2 mean ORDER_FILLING_RETURN, but this filling mode is not accepted by FxPro server. I've the same problem and  I've no idea how to check requested ENUM_ORDER_TYPE_FILLING mode.

Regards

Zbyszko 

 

Hi Alain,

Many thanks for your help again ;-)

Below is the piece of code in its simplest form that I use with my EA (PS, it is a basic EA not automated, it just uses buttons to open & close trades, at least I can test and see the actions in real time before to push development further).

#include<Trade\Trade.mqh>
CTrade  trade;

==> Init
         //Set CTrade infos
            trade.SetExpertMagicNumber(MagicNumberUsed);
            trade.SetDeviationInPoints(slippage);
            trade.SetTypeFilling(ORDER_FILLING_IOC);
            trade.SetAsyncMode(false);

==> Open trade on button click:
            ENUM_ORDER_TYPE order_type = ORDER_TYPE_BUY;

            int ticket = trade.PositionOpen(_Symbol, order_type, 0.01, SymbolInfoDouble(_Symbol,order_type==ORDER_TYPE_SELL ? SYMBOL_BID:SYMBOL_ASK), 0, 0, "Coment");
==> Close trade on button click:

   //Here what I thought would be applicable:
            for (int i = PositionsTotal() -1; i >= 0; i--)
            {
                  ulong ticket=PositionGetTicket(i);
                  
                  if (PositionGetInteger(POSITION_MAGIC) != MagicNumberUsed) continue;
                  if (PositionGetSymbol(i) != symbol) continue;

                  bool result = trade.PositionClose(ticket, 100);
            }//End for
   //And finally here what I use at the moment to close orders in the netting mode:
         if(!is_Hedging)
         {
            for (int i = PositionsTotal() -1; i >= 0; i--)
            {
                  ulong ticket=PositionGetTicket(i);
                  
                  if (PositionGetInteger(POSITION_MAGIC) != MagicNumberUsed) continue;
                  if (PositionGetSymbol(i) != symbol) continue;

                  double Lot_Id = PositionGetDouble(POSITION_VOLUME);

                  if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
                  {
                     result = trade.PositionOpen(_Symbol, ORDER_TYPE_SELL, Lot_Id, SymbolInfoDouble(_Symbol, SYMBOL_BID), 0, 0, "Close Buy");
                  }
        
                  if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
                  {
                     result = trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, Lot_Id, SymbolInfoDouble(_Symbol, SYMBOL_ASK), 0, 0, "Close Sell");
                        //result = trade.PositionClose(ticket, 1000);
                  }
            }//End for

         }//End (!is_Hedging)

I think/hope it make sense?

Thanks again, Regards,

G

 
trade.SetTypeFilling(ORDER_FILLING_IOC);

It's ok, but the question is, how to check requested filling type automatically? 

"SymbolInfoInteger(_Symbol, SYMBOL_FILLING_MODE);" returns invalid ENUM_ORDER_TYPE_FILLING mode.

Regards

 

Here, as explained in my first post, the SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE) return 2 which mean SYMBOL_FILLING_IOC so I have tested both SYMBOL_FILLING_IOC and SYMBOL_FILLING_FOK and same filling issue.

I have not tried to change the filling mode for trade closure only, but I don’t think it make sense at all?

Regards,

G

 
gringoh:

Here, as explained in my first post, the SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE) return 2 which mean SYMBOL_FILLING_IOC

It is not true. I checked in my EA this code:

   ENUM_ORDER_TYPE_FILLING filling = SymbolInfoInteger(_Symbol, SYMBOL_FILLING_MODE);
   Comment(StringFormat("%i | %i", filling, ORDER_FILLING_IOC));

 And the result is: 2 | 1, so ORDER_FILLING_IOC mean 1.

 

Thanks for the additional info ;-)

 
gringoh:

Thanks for the additional info ;-)

I think it's an error in MT5 or in documentation. I found this: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#symbol_filling_mode

where is written that value of SYMBOL_FILLING_FOK is 1 and value of SYMBOL_FILLING_IOC is 2. This is wrong.

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
Zbigniew Sobczyk:

I think it's an error in MT5 or in documentation. I found this: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#symbol_filling_mode

where is written that value of SYMBOL_FILLING_FOK is 1 and value of SYMBOL_FILLING_IOC is 2. This is wrong.


To be honest, I am completely lost, what I have coded above is working fine but in order to close an order, I tought a simple trade.PositionClose(ticket, 1000); would work and no.

Reason: