
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
You misunderstood.
It was the server that did not send the order status PLASED for 20 seconds.
There is an obvious error in the terminal, where theORDER_STATE_STARTED order status "hangs".
Has it been finally sorted out?
What exactly did the exchange say about this order? Was it placed quickly? If so, it is obvious that there was an error on the server or MT terminal that did not update the status. And with this you can go to the service-desk.
As a result of the discussion on the problem with Michael at Service Desk:
Apparently we need to explain how the order system works and what the placement means.
So:
1. You send a request
2. MT5 server checks this request (parameters, pre-trade, etc.). If there is a problem, you will get a corresponding error code in response to the request.
After that you create a new order giving it a ticket (#24025010) - herewith the state "started" is set for the order. The order ticket is used to link the order identifier in MT5 with the order on the exchange at the moment of placing the order on the exchange.
The terminal sends a transaction about adding a new order in the "started" state, which can be tracked in OnTradeTransaction.
3. Next, the trade server (via the gateway) sends your order to the exchange, if the request was successfully sent, your request will receive a response - this means
"that the request has been sent", the results will be executed asynchronously, as you do not know in advance how long the exchange will reply.
Respectively it is at this point you see the record in the journal
4. After some time, the exchange sets the order in its system, assigns an identifier to it and then notifies the gateway and MT5 server.
If the exchange has set the order, the order identifier is written in the order in MT5 and the order status changes with => placed.
If the exchange refuses to place an order for some reason, the order will be removed.
This can all be tracked by simply logging the transactions coming into OnTradeTransaction.
================================================================================
What happens:
1. You submit an order request - see steps 1-3.
And at the moment when the order is already in MT5, and there is no order on the exchange, you send an order to withdraw this order.
You need to make appropriate checks-corrections in the logic of your EA.But since this order is in its initial state (started) and the existence of an order for it is not defined, you receive a refusal to withdraw the order
.
Z.U. The other thing is that within a second.
(and moreover for 20 seconds) the order should have been placed, this is being dealt with, one of the potential problems has been found - we are correcting it.As a result of the discussion on the problem with Michael at Service Desk:
Apparently we need to explain how the order system works and what the placement means.
So:
1. You send a request
2. MT5 server checks this request (parameters, pre-trade, etc.). If there is a problem, you will get a corresponding error code in response to the request.
After that you create a new order giving it a ticket (#24025010) - herewith the state "started" is set for the order. The order ticket is used to link the order identifier in MT5 with the order on the exchange at the moment of placing the order on the exchange.
The terminal sends a transaction about adding a new order in the "started" state, which can be tracked in OnTradeTransaction.
3. Next, the trade server (via the gateway) sends your order to the exchange, if the request was successfully sent, your request will receive a response - this means
"that the request has been sent", the results will be executed asynchronously, as you do not know in advance how long the exchange will reply.
Respectively it is at this point you see the record in the journal
4. After some time, the exchange sets the order in its system, assigns an identifier to it and then notifies the gateway and MT5 server.
If the exchange has set the order, the order identifier is written in the order in MT5 and the order status changes with => placed.
If the exchange refuses to place the order for some reason, the order will be removed.
All of this can be tracked by simply logging the transactions coming into OnTradeTransaction.
================================================================================
What happens:
1. You submit an order request - see steps 1-3.
And at the moment when the order is already in MT5, and there is no order on the exchange, you send an order to withdraw this order.
You need to make appropriate checks-corrections in the logic of your EA.But since this order is in its initial state (started) and the existence of an order for it is not defined, you receive a refusal to withdraw the order
.
Z.U. The other thing is that within a second
(and moreover, for 20 seconds) the order should be placed, we are dealing with it, we have found one of the potential problems - let's fix it.It is not clear at what point the state of the order "started" changes to "placed". Does this happen according to point 3 of your explanation, according to point 4 of your explanation or in both cases point 3 and 4?
4. After some time, the exchange sets the order in its system, assigns its identifier, and then notifies the gateway and MT5 server about it.
If the exchange has set the order - the order identifier is written into the order in MT5, and the order state changes from started => placed.
3. Then the trading server (via gateway) sends your request to the exchange, if the request was successfully sent, then your request will be answered, which means
"that the request has been sent", the results of its work will be executed asynchronously, because you do not know in advance what time the exchange response.
Accordingly, it is at this point you see in the journal entry
2015.11.26 10:48:23.726 Trades 'xxxxxx': buy limit 5.00 SNGR-3.16 at 35501 placed for execution in 7 ms
4. After some time, the exchange sets the order in its system, assigns an identifier to it and then notifies the gateway and MT5 server.
If the exchange has set the order, the identifier of the order in MT5 is written in the order in MT5 and the order status changes with => placed.
Here is another reason for confusion: in the log it says that the order has already been placed, but in fact its state has not yet changed.
Maybe we should write something like "sent" instead of "placed" because the order has not actually been accepted by the exchange?
It turns out the following.
Before ( or after ) performing any action on an order,
you have to "check" its status each time (correct me if I'm not sure):
It turns out the following.
Before ( or after ) performing any action on an order,
you have to "check" its state each time (correct me if I missed something):
Wrong,
If we look at theHistoryOrderSelect( ticket ), then we need to applyHistoryOrderGetInteger(),HistoryOrderGetDouble()
Incorrect,
If we look inHistoryOrderSelect( ticket ), we need to applyHistoryOrderGetInteger(),HistoryOrderGetDouble()
Right, it's a misprint :)
Thank you, corrected it...