Hello everybody
I have written a simple EA that randomly places at every tick a buy or sell order, below I put the relevant part of the code. However, when I try to use it on EURUSD, where Market orders are allowed (price specification is not required), I always get a trade return code 10015, Invalid price in the request. But, according to https://www.mql5.com/en/docs/constants/structures/mqltraderequest to open a position in the Market Execution mode it is necessary to specify 0nly the following 5 fields:
•action
•symbol
•volume
•type
•type_filling
Change the following line of code :
MqlTradeRequest mrequest = {0}; //
Change the following line of code :
Hello everybody
I have written a simple EA that randomly places at every tick a buy or sell order, below I put the relevant part of the code. However, when I try to use it on EURUSD, where Market orders are allowed

- www.mql5.com
I still get the same error. BTW, when I debug the code, with both the modification you suggest and not, the mrequest.price is always set to 0.0, and I think this is causing the problem.
Maybe the problem was caused by your account settings. Does your broker offer Market Execution on EURUSD? Is your account a STP/ECN account?
In the link: https://www.mql5.com/en/docs/constants/structures/mqltraderequest, I found this:
Price, reaching which the order must be executed. Market orders of symbols, whose execution type is "Market Execution" (SYMBOL_TRADE_EXECUTION_MARKET), of TRADE_ACTION_DEAL type, do not require specification of price.

- www.mql5.com
I still get the same error. BTW, when I debug the code, with both the modification you suggest and not, the mrequest.price is always set to 0.0, and I think this is causing the problem.
Then you are probably not in an Market execution symbol. Do you check that ?
long symbol_execution_mode; if(SymbolInfoInteger(Symbol(),SYMBOL_TRADE_EXEMODE,symbol_execution_mode)) { Print("Symbol : ", Symbol(), " execution mode = ", EnumToString((ENUM_SYMBOL_TRADE_EXECUTION)symbol_execution_mode)); }

- www.mql5.com
You're all right, in fact execution mode for EURUSD is set to EXECUTION_INSTANT. But I am still confused, since I first checked with this code what kind of orders were allowed for EURUSD:
void Check_SYMBOL_ORDER_MODE(string symbol) { //--- receive the value of the property describing allowed order types int symbol_order_mode=(int)SymbolInfoInteger(symbol,SYMBOL_ORDER_MODE); //--- check for market orders (Market Execution) if((SYMBOL_ORDER_MARKET&symbol_order_mode)==SYMBOL_ORDER_MARKET) Print(symbol+": Market orders are allowed (price specification is not required)"); //--- check for Limit orders if((SYMBOL_ORDER_LIMIT&symbol_order_mode)==SYMBOL_ORDER_LIMIT) Print(symbol+": Buy Limit and Sell Limit orders are allowed"); //--- check for Stop orders if((SYMBOL_ORDER_STOP&symbol_order_mode)==SYMBOL_ORDER_STOP) Print(symbol+": Buy Stop and Sell Stop orders are allowed"); //--- check for Stop Limit orders if((SYMBOL_ORDER_STOP_LIMIT&symbol_order_mode)==SYMBOL_ORDER_STOP_LIMIT) Print(symbol+": Buy Stop Limit and Sell Stop Limit orders are allowed"); //--- check if placing a Stop Loss orders is allowed if((SYMBOL_ORDER_SL&symbol_order_mode)==SYMBOL_ORDER_SL) Print(symbol+": Stop Loss orders are allowed"); //--- check if placing a Take Profit orders is allowed if((SYMBOL_ORDER_TP&symbol_order_mode)==SYMBOL_ORDER_TP) Print(symbol+": Take Profit orders are allowed"); //--- } void OnStart() { //--- Check_SYMBOL_ORDER_MODE(_Symbol); }
and the result was
2013.09.16 12:26:03 testscript3 (EURUSD,M1) EURUSD: Take Profit orders are allowed
2013.09.16 12:26:03 testscript3 (EURUSD,M1) EURUSD: Stop Loss orders are allowed
2013.09.16 12:26:03 testscript3 (EURUSD,M1) EURUSD: Buy Stop Limit and Sell Stop Limit orders are allowed
2013.09.16 12:26:03 testscript3 (EURUSD,M1) EURUSD: Buy Stop and Sell Stop orders are allowed
2013.09.16 12:26:03 testscript3 (EURUSD,M1) EURUSD: Buy Limit and Sell Limit orders are allowed
2013.09.16 12:26:03 testscript3 (EURUSD,M1) EURUSD: Market orders are allowed (price specification is not required)
So can anybody explain me if there is or not a contradiction between the output of last line "Market orders are allowed (price specification is not required)" and the fact that the symbol is not in market execution type?
Does it depend on the broker (for testing I use the demo account provided by MetaQuotes)?
You're all right, in fact execution mode for EURUSD is set to EXECUTION_INSTANT. But I am still confused, since I first checked with this code what kind of orders were allowed for EURUSD:
...
So can anybody explain me if there is or not a contradiction between the output of last line "Market orders are allowed (price specification is not required)" and the fact that the symbol is not in market execution type?
Does it depend on the broker (for testing I use the demo account provided by MetaQuotes)?
Ok I See. The code you are using comes from a page on documentation which contains an error. I already report this to ServiceDesk.
2013.09.16 12:26:03 testscript3 (EURUSD,M1) EURUSD: Market orders are allowed (price specification is not required)
Order Mode returns allowed order's type which is Buy/Sell, Pending orders of all sorts,... Buy/Sell is also called Market Order. And there is a mix in documentation with Market Execution mode. I suppose the documentation will be updated soon.
So for Market Execution you don't have to specify a price. (Exchange execution is the same as Market execution).
For Instant Execution you have to specify a price. (Request execution is actually the same as Instant).
You're all right, in fact execution mode for EURUSD is set to EXECUTION_INSTANT. But I am still confused, since I first checked with this code what kind of orders were allowed for EURUSD:
So can anybody explain me if there is or not a contradiction between the output of last line "Market orders are allowed (price specification is not required)" and the fact that the symbol is not in market execution type?
Does it depend on the broker (for testing I use the demo account provided by MetaQuotes)?
You are checking the wrong thing . . . check this: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_trade_execution
Yes, it does depend on your Broker.

- www.mql5.com
You are checking the wrong thing . . . check this: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_trade_execution
Yes, it does depend on your Broker.
The issue in reference has been fixed - https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants. Sorry for delay
When sending a trade request using OrderSend() function, an order type from ENUM_ORDER_TYPE enumeration should be specified for some operations. Not all types of orders may be allowed for a specific symbol. SYMBOL_ORDER_MODE property describes the flags of the allowed order types.
Identifier |
Value |
Description |
SYMBOL_ORDER_MARKET |
1 |
Market orders are allowed (Buy and Sell) |
SYMBOL_ORDER_LIMIT |
2 |
Limit orders are allowed (Buy Limit and Sell Limit) |
SYMBOL_ORDER_STOP |
4 |
Stop orders are allowed (Buy Stop and Sell Stop) |
SYMBOL_ORDER_STOP_LIMIT |
8 |
Stop-limit orders are allowed (Buy Stop Limit and Sell Stop Limit) |
SYMBOL_ORDER_SL |
16 |
Stop Loss is allowed |
SYMBOL_ORDER_TP |
32 |
Take Profit is allowed |
Example:
//+------------------------------------------------------------------+//| The function prints out order types allowed for a symbol |
//+------------------------------------------------------------------+
void Check_SYMBOL_ORDER_MODE(string symbol)
{
//--- receive the value of the property describing allowed order types
int symbol_order_mode=(int)SymbolInfoInteger(symbol,SYMBOL_ORDER_MODE);
//--- check for market orders (Market Execution)
if((SYMBOL_ORDER_MARKET&symbol_order_mode)==SYMBOL_ORDER_MARKET)
Print(symbol+": Market orders are allowed (Buy and Sell)");

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody
I have written a simple EA that randomly places at every tick a buy or sell order, below I put the relevant part of the code. However, when I try to use it on EURUSD, where Market orders are allowed (price specification is not required), I always get a trade return code 10015, Invalid price in the request. But, according to https://www.mql5.com/en/docs/constants/structures/mqltraderequest to open a position in the Market Execution mode it is necessary to specify 0nly the following 5 fields:
•action
•symbol
•volume
•type
•type_filling