Orders accepted and cancelled right away - page 2

 

After one entire day fighting with this same problem, I was able to manage its solution.  The type_filling property should be set to ORDER_FILLING_RETURN:

MqlTradeRequest vrequest={0};

vrequest.type_filling=ORDER_FILLING_RETURN;

I hope this can help out someone here.
 
elton.lima: After one entire day fighting with this same problem, I was able to manage its solution.  The type_filling property should be set to ORDER_FILLING_RETURN. I hope this can help out someone here.

You should not be guessing or using trail and error! You should be checking for the valid Filling Modes for the Symbol in question (see example below).

When sending an order, you can specify the filling policy for the volume set in the order. Allowed order filling modes for each symbol are specified in the table. You can set several modes for one symbol by combining flags. The flags can be combined by the operation of the logical OR (|), for example, SYMBOL_FILLING_FOK|SYMBOL_FILLING_IOC.  In order to check whether a certain mode is allowed for the symbol, the result of the logical AND (&) should be compared to the mode flag.

Fill Policy

Identifier

Value

Description

Fill or Kill

SYMBOL_FILLING_FOK

1

This policy means that a deal can be executed only with the specified volume. If the necessary amount of a financial instrument is currently unavailable in the market, the order will not be executed. The required volume can be filled using several offers available on the market at the moment.

Immediate or Cancel

SYMBOL_FILLING_IOC

2

In this case a trader agrees to execute a deal with the volume maximally available in the market within that indicated in the order. In case the order cannot be filled completely, the available volume of the order will be filled, and the remaining volume will be canceled. The possibility of using IOC orders is determined at the trade server.

Return

No identifier

 

This policy is used only for market orders (Buy and Sell), limit and stop limit orders and only for the symbols with Market or Exchange execution. In case of partial filling a market or limit order with remaining volume is not canceled but processed further.

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.

Example:

//+------------------------------------------------------------------+
//| Checks if the specified filling mode is allowed                  |
//+------------------------------------------------------------------+
bool IsFillingTypeAllowed(string symbol,int fill_type)
  {
//--- Obtain the value of the property that describes allowed filling modes
   int filling=(int)SymbolInfoInteger(symbol,SYMBOL_FILLING_MODE);
//--- Return true, if mode fill_type is allowed
   return((filling & fill_type)==fill_type);
  }

Reason: