ORDER_STATE_REJECTED - after which ENUM_TRADE_REQUEST_ACTIONS ?

 

Hi,

ORDER_STATE_REJECTED does for sure apply to TRADE_ACTION_DEAL (sending a market order using OrderSend()) and TRADE_ACTION_PENDING (sending a pending order using OrderSend()), but how about the other  ENUM_TRADE_REQUEST_ACTIONS values?


I assume that it doesn't apply to TRADE_ACTION_SLTP, as it is an operation purely related to existing position - and indeed, after SL/TP modification, the OnTradeTransaction() event handler catches 2 events - TRADE_TRANSACTION_POSITION and TRADE_TRANSACTION_REQUEST, but no trade transaction events related to orders.

But how about TRADE_ACTION_MODIFY, TRADE_ACTION_REMOVE, TRADE_ACTION_CLOSE_BY? I assume it doesn't apply to these 3 as well, as these actions are related either to an order that has already been accepted by the broker ( ORDER_STATE_PLACED) and is now being either modified or removed, or (in a 3rd case) to a request to close an existing position with another existing posistion - which doesn't require sending additional orders (despite it is related to ORDER_TYPE_CLOSE_BY order in the history orders database - but when you close a position by another one using OrderSend(), you do not specify any order-related data, but 2 position tickets).

Logically it also seems that given the available ENUM_ORDER_STATE values, first the order is started (ORDER_STATE_STARTED), than it can change its state to ORDER_STATE_PLACED or ORDER_STATE_REJECTED, and if it not rejected - it can move from a placed order into 4 remaining states. So ORDER_STATE_REJECTED could only happen after ORDER_STATE_STARTED.

After performing few different transactions and listening to TradeTransaction events, it also seems logical to me that the ORDER_STATE_REJECTED could happen only for TRADE_ACTION_DEAL and TRADE_ACTION_PENDING - as sending market or pending orders and SL/TP triggering were the only 3 cases in which I have observed  ORDER_STATE_STARTED - and SL/TP triggering doesn't happen as a result of a any of ENUM_TRADE_REQUEST_ACTION, but as a result of market price reaching SL/TP on an existing position.


Any thoughts/comments anyone?

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Trading is done by sending orders to open positions using the OrderSend() function, as well as to place, modify or delete pending orders. Each trade order refers to the type of the requested operation. Trading operations are described in the ENUM_TRADE_REQUEST_ACTIONS enumeration...