Hello,
I have a problem with execution of market orders - they always return error "Invalid stops", though I provide all the necessary data according to https://www.mql5.com/en/docs/constants/structures/mqltraderequest. I use MetaQuates-Demo and I succeed in submitting order of type Instant Execution in the terminal. Here are the screenshots from and afterwards is the code that I use to send order from MQL5. The OrderSend method results with code 10016 and message "Invalid stops".
There is the source code:
Could you please explain me what happens and what I can do to execute market orders from my EAs with the demo account? Thank you in advance!
Kind Regards,
Petrov
You need to add request.price, request.tp and request.sl like this :
request.price = SymbolInfoDouble(_Symbol,SYMBOL_ASK); request.tp = request.price+TP*_Point; request.sl = request.price-SL*_Point;
You need to read the documentation from MQL5 and to see the examples.
achidayat, I know that it is going to work in the way you propose, but I think this is something different. In a market order I am not required to provide a price and SL/TP values. This is written in the documentation (the link I included in my post).
JMRodMartins, I wouldn't have asked if I haven't read the documentation and tried a number of times, including examples from there. However, I may have missed something useful. Can you be more concrete about what part of the documentation with what examples to see?
And how your problem corresponds with Trading Systems branch? Why no General or Experts Advisors and Automated Trading?
And how your problem corresponds with Trading Systems branch? Why no General or Experts Advisors and Automated Trading?
If this don't work, just post the final code here again to we double check.

- www.mql5.com
Hi Petrov, insert and test achidayat sl/tp posted code, I suggest you use normalizedouble function for prices too.
If this don't work, just post the final code here again to we double check.
Hi figurelli,
I have tried adding the price, sl and tp and as expected the order was sent successfully. This is my code:
void OnInit() { MqlTradeRequest request; request.action = TRADE_ACTION_DEAL; request.symbol = _Symbol; request.volume = 0.1; request.type = ORDER_TYPE_BUY; request.type_filling = ORDER_FILLING_FOK; request.price = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); request.tp = NormalizeDouble(request.price + 100 * _Point, _Digits); request.sl = NormalizeDouble(request.price - 100 * _Point, _Digits); MqlTradeResult result; OrderSend(request, result); }
However, I want to send a simple market order without specifying the price, sl and tp. According to the documentation https://www.mql5.com/en/docs/constants/structures/mqltraderequest this is possible. There it says:
Market Execution
This is a trade order to open a position in the Market Execution mode. It requires to specify the following 5 fields:
- action
- symbol
- volume
- type
- type_filling
Also it is possible to specify the "magic" and "comment" field values.
So I send a request with exactly the same 5 required fields:
void OnInit() { MqlTradeRequest request; request.action = TRADE_ACTION_DEAL; request.symbol = _Symbol; request.volume = 0.1; request.type = ORDER_TYPE_BUY; request.type_filling = ORDER_FILLING_FOK; MqlTradeResult result; OrderSend(request, result); }
As a result it says "Invalid stops". This doesn't make sense! It looks that either the documentation is wrong or there is some bug in the platform... Or I miss something. Do you have any explanation about what happens?

- www.mql5.com
Hi,
You should always specify the buy/sell price.
You can get it using MqlTick structure and SymolTick function to copy the last quotes inot the structure.
Invalid stops error might be caused by the execution type of your broker. Some brokers (ECN) do not allow placing SL/TP together with the opening order. In this case you should perform your deal in 2 steps.
1. You open a position WITHOUT sl and tp
2. You put your SL and TP using another order send request. (TRADE_ACTION_SLTP)
Hope it helps.
Andrey.

- www.mql5.com
In this documentation : https://www.mql5.com/en/docs/constants/structures/mqltraderequest
Do You mean in "Market Execution" section ?
Market Execution
This is a trade order to open a position in the Market Execution mode. It requires to specify the following 5 fields:
- action
- symbol
- volume
- type
- type_filling
So the problem is what different of Request Execution mode, Instant Execution mode, Exchange Execution mode, and Market Execution mode? It need explanation.

- www.mql5.com
In this documentation : https://www.mql5.com/en/docs/constants/structures/mqltraderequest
Do You mean in "Market Execution" section ?
Market Execution
This is a trade order to open a position in the Market Execution mode. It requires to specify the following 5 fields:
- action
- symbol
- volume
- type
- type_filling
So the problem is what different of Request Execution mode, Instant Execution mode, Exchange Execution mode, and Market Execution mode? It need explanation.
Yes, I mean Market Execution section.
So it looks that I am not in Market Execution mode and that's why I need more fields filled (price, sl and tp) - is this correct?
If this is the case, then how can I change the execution mode to Market Execution?

- 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,
I have a problem with execution of market orders - they always return error "Invalid stops", though I provide all the necessary data according to https://www.mql5.com/en/docs/constants/structures/mqltraderequest. I use MetaQuates-Demo and I succeed in submitting order of type Instant Execution in the terminal. Here are the screenshots from and afterwards is the code that I use to send order from MQL5. The OrderSend method results with code 10016 and message "Invalid stops".
There is the source code:
Could you please explain me what happens and what I can do to execute market orders from my EAs with the demo account? Thank you in advance!
Kind Regards,
Petrov