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
Something I'm not good at explaining, apparently. Here's a real-life example. Here is the code:
and so on.
We can see that the response time of OnTradeTransaction in two Expert Advisors coincides to milliseconds. So, I have a question: does the "deal" event comes first to one OnTradeTransaction in one EA and then to the next one in another EA or does it somehow get to all handlers of all EAs at once? You know, like a parallel multi-threaded operation or whatever it is called in programming. I'm sure that everything happens sequentially, it is just processed within one millisecond, but I asked just in case.
Something I'm not good at explaining, apparently. Here's a real-life example. Here is the code:
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result)
{
Count++;
Print("Ontrade_test = ",Count);
}
The handler is implemented in two Expert Advisors so it is executed multiple times in two Expert Advisors when one trade is performed. The code produces:
18:31:06.495 ontrade_trans_functions (MXI-12.17,H1) Ontrade_test = 1
18:31:06.495 ontrade_trans_functions2 (MXI-12.17,H1) Ontrade_test = 1
18:31:06.497 ontrade_trans_functions (MXI-12.17,H1) Ontrade_test = 2
18:31:06.497 ontrade_trans_functions2 (MXI-12.17,M5) Ontrade_test = 2
18:31:06.498 ontrade_trans_functions (MXI-12.17,M5) Ontrade_test = 3
18:31:06.498 ontrade_trans_functions2 (MXI-12.17,H1) Ontrade_test = 3
18:31:06.500 ontrade_trans_functions (MXI-12.17,M5) Ontrade_test = 4
18:31:06.500 ontrade_trans_functions2 (MXI-12.17,H1) Ontrade_test = 4 ...
and so on.
You can see that the OnTradeTransaction response time in the two Expert Advisors is the same in milliseconds. So, I have a question: does the trade event comes first to one OnTradeTransaction in one EA and then to the next one in another EA or does it somehow get to all handlers of all EAs at once? Well, it's like a parallel multi-threaded operation or whatever it is called in programming. I'm sure that everything happens sequentially, it just works fast within one millisecond, but I asked just in case.
OnTradeTransaction handler for ONE symbol (m_symbol.Name()) and one magic (m_magic).
Catch the transaction first
TRADE_TRANSACTION_DEAL_ADD
Add the transaction to the history. This is done as a result of order execution or account balance transactions.
then we look to see if it is a trade
DEAL_ENTRY_OUT
Market exit
The eventOnTradeTransaction is a broadcast event, all the actions that your terminal performs are "dumped" there.
It is just that each EA has to filter its own actions.
Then in each type, we filter by ticket, if the order is sent asynchronously, then
first, we get the ticket by its request ID and then we filter by the ticket.
TheTRADE_TRANSACTION_REQUEST eventalways comes first, the others "as they want".
Added
This has been discussed many times.
Look it up in Exchange Trading
Thanks, seems to be getting the right deals "written down".