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
Use it.
This is a good example. But I have a question. What if OnTradeTransaction() doesn't return the data on order processing? Well, they may be lost somehow. The server has sent it but the terminal has not received it. How much is it guaranteed that I will get the required number of OnTradeTransaction() function calls for 100% of orders sent and all transaction reports will reach the terminal (I am interested in transaction.type = TRADE_TRANSACTION_REQUEST mainly).
Because if I don't get this response (because of connection break, for example) I won't clear the flag and everything will stand up.
I haven't checked, but maybe after OrderSend ALL EAs get corresponding event for OnTradeTransaction.
Then everything is solved without crutches and for multiple EAs on the same symbol.
This is a good example. But here's a question that's bugging me. What if OnTradeTransaction() doesn't return the order processing data? Well, they may be lost somehow. The server has sent it but the terminal hasn't received. How much is it guaranteed that I will get the required number of OnTradeTransaction() function calls for 100% of orders sent and all transaction reports will reach the terminal (I am interested in transaction.type = TRADE_TRANSACTION_REQUEST mainly).
Because if I don't get this response (because of connection break, for example) I won't remove flag and everything will stand.
I had several times that OnTradeTransaction event didn't occur,
therefore I wrote a function that checks state of orders using a timer with a period of 0.5 seconds.
The implementation complicates the general code of the Expert Advisor, but there is no 100% guarantee when working over the Internet,
that everything will run like clockwork.
Added by
I got the idea of checking here
https://www.mql5.com/ru/blogs/post/557544
I had several times that OnTradeTransaction event didn't happen,
Therefore, I wrote a function that checks the state of orders using a timer with a period of 0.5 seconds.
The implementation complicates the general code of the Expert Advisor, but there is no 100% guarantee when working over the Internet,
that everything will run like clockwork.
Added by
I got the idea of checking here
https://www.mql5.com/ru/blogs/post/557544
It seems to me that the guy is trying to break through an open door by creating special magic codes for each transaction. There is an order_id by which an order can be uniquely identified.
Or am I missing the point?
It seems to me that the guy is breaking through an open door by creating special magic codes for each trade. There is an order_id which can be used to uniquely identify the order.
Or am I missing the point?
Yes, there is an order_id, but unfortunately sometimes events don't come to OnTradeTransaction
(I had it several times personally).
And then where to "put" the order_id ?
Added by
Here, there was a server response delay today
2016.12.28 14:04:56.443 (GOLD-3.17,M1) CheckOrders: Задержка ответа сервера. Ожидание продолжается...
Yes, there is an order_id, but unfortunately sometimes events don't come in OnTradeTransaction
(I had it a few times personally).
Where to "stuff" the order_id then ?
Added by
Here, there was a server response delay today
2016.12.28 14:04:56.443 (GOLD-3.17,M1) CheckOrders: Задержка ответа сервера. Ожидание продолжается...
I had a different "baffle" the other day.
2016.12.23 15:04:02.924 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction EURUSD Retcode = 10009. Slippage = 1631.
2016.12.23 15:04:02.924 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction EURUSD Position is closed in 59699 mksec.
2016.12.23 15:04:02.924 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction EURUSD Retcode = 10009. Slippage = 1631.
2016.12.23 15:04:02.924 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction EURUSD Position is closed in 59712 mksec.
2016.12.23 15:04:02.992 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction GBPUSD Retcode = 10009. Slippage = 1379.
2016.12.23 15:04:02.992 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction GBPUSD Position is closed in 127691 mksec.
2016.12.23 15:04:02.992 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction All reposts are checked. Direction = 0
2016.12.23 15:04:02.993 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction Unexpected transaction request.
2016.12.23 15:04:02.993 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction EURGBP Retcode = 10009. Slippage = -40993.
2016.12.23 15:04:02.993 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction EURGBP Position is closed in 1339448077 mksec.
2016.12.23 15:04:02.993 TriArbTrader_8-4 (EURGBP,H1) 1111 OnTradeTransaction All reposts are checked. Direction = -1
Three orders were sent, and there's a clear record of it in the log. After that, function OnTradeTransactions() TRADE_TRANSACTION_TYPE has been called four times.
The function code starts with checks:
const MqlTradeRequest& request,
const MqlTradeResult& results)
{
if(transaction.type == TRADE_TRANSACTION_REQUEST && request.action == TRADE_ACTION_DEAL)
{
if(request.magic == ExpertMagic)
{
That is, only TRADE_TRANSACTION_REQUIEST with its own stamp of expert can go inside, where the printers stand...
Helpdesk first started to persuade me that I have two identical EAs standing (obviously on the same chart, judging by the log). And then they said: "you're a fool, fix the errors in the code".
In short, according to them it can not be. But the log clearly shows that the event came four times.
Yes, there is an order_id, but unfortunately sometimes events don't come in OnTradeTransaction
(I had it a few times personally).
Where to "stuff" the order_id then ?
Added by
Here, today I had a server response delay.
2016.12.28 14:04:56.443 (GOLD-3.17,M1) CheckOrders: Задержка ответа сервера. Ожидание продолжается...
But anyway, I still do not understand why we cannot search for order by ticker? It is very easy to check which of the orders we have sent did not come to TradeTransaction. And then just look at the status of the order with this ticket in the history.
Although, the order history shows only orders with the status FILLED.
And still it is not clear why the order cannot be searched by ticker? After all, it is easy to check which order has not come to TradeTransaction. And then just look at the status of the order with this ticker in the history.
Although, when I personally tried it, in the order history, there were only orders with the status FILLED.
Yes, because the order may not be in the history(pending order, etc.)
Added
And you have the wrong code
Yes, because the order may not be in the history(pending order, etc.)
Added by
And you have the wrong code
What's wrong there? How many mistakes can you make in two lines of code.
What is wrong there? How many mistakes can be made in two lines of code.
Not two, one :)
TRADE_TRANSACTION_REQUEST is needed when you use OrderSendAsymc to get the order ticket.