MQL5 : "request.deviation" & "OrderSendAsync("

 
Hi,

My OrderSendAsync returns true (sent ok) but the order isn't executed.
I suppose this is because of request.deviation (because if I put a higher value, then orders are executed).

How can I determine, for sure, that my orders are rejected because of a request.deviation that is too low?

Thanks
 

Read the help - there are many answers.  OrderSendAsync

Return Value

Returns true if the request is sent to a trade server. In case the request is not sent, it returns false. In case the request is sent, in the result variable the response code contains TRADE_RETCODE_PLACED value (code 10008) – "order placed". Successful execution means only the fact of sending, but does not give any guarantee that the request has reached the trade server and has been accepted for processing. When processing the received request, a trade server sends a reply to a client terminal notifying of change in the current state of positions, orders and deals, which leads to the generation of the Trade event.

The result of executing the trade request on a server sent by OrderSendAsync() function can be tracked by OnTradeTransaction handler. It should be noted that OnTradeTransaction handler will be called several times when executing one trade request.

For example, when sending a market buy order, it is handled, an appropriate buy order is created for the account, the order is then executed and removed from the list of the open ones, then it is added to the orders history, an appropriate deal is added to the history and a new position is created. OnTradeTransaction function will be called for each of these events. To get such a data, the function parameters should be analyzed:

    • trans - this parameter gets MqlTradeTransaction structure describing a trade transaction applied to a trade account;
    • request - this parameter gets MqlTradeRequest structure describing the trade request resulted in a trade transaction;
    • result - this parameter gets MqlTradeResult structure describing a trade request execution result.
Documentation on MQL5: Trade Functions / OrderSendAsync
Documentation on MQL5: Trade Functions / OrderSendAsync
  • www.mql5.com
OrderSendAsync - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Thanks, I have already read this, there's no retcode indicating that order was rejected because of an allowed price deviation too low.... correct?

https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes

Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
Trade Server Return Codes - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
ccou # :

Thanks, I have already read this, there's no retcode indicating that order was rejected because of an allowed price deviation too low.... correct?

https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes

Just use the synchronous function:

OrderSend

Sends trade requests to a server

Documentation on MQL5: Trade Functions / OrderSend
Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
OrderSend - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

What is the Trade error "return code" that the synchronous will give, if the allowed "price deviation" is too low and the broker rejects the order?

Thanks

 
Some common error causes and corresponding return codes from mt5 trade server:

failed to pend new order: 10006
pending order already triggered, modify pending order failed: 10013
pending price modify failed due to market change or other reason: 10015
position stop-loss price modify failed due to market change or other reason: 10016

In most cases, the software architecture of forex dealers that natively supports MT5 can provide relatively reliable information feedback back to MT5 clients via two functions: OnTradeTransaction() and OnTrade().

However, some stock/futures brokers have to use the bridge service to provide MT5 trading platform support, and the feedback from the server is less reliable, which I found out through real money losses.

 
ccou # :

What is the Trade error "return code" that the synchronous will give, if the allowed "price deviation" is too low and the broker rejects the order?

Thanks

Could be code

10004

TRADE_RETCODE_REQUOTE

Requote

Reason: