Thanks. Let me try it out and revert !
Hi Yashar,
Thank, DEAL_TYPE indeed return there right DEAL_TYPE.
However, based on my testing, OnTradeTransaction indeed has the limitation.
For example, if inside your OnTradeTransaction you have 5 step to run, if while it is running certain step 3 in OnTradeTransaction and then there is another deal come in, it will continue the step 4 with new deal instead of previous deal. It is rare and only happen when there is deal that happen in same second, but if will become more often, if you are running your EA on multiple symbol on different chart. I saw case that the the deal from different chart overwrite and run the remaining step in OnTradeTransaction. Sound like this event is running on a single thread.
I really hope Metatrader team fix this limitation. If not, this OnTradeTransaction can't usable on a very high trading frequency scenario.
Thanks.
Hi Yashar,
Thank, DEAL_TYPE indeed return there right DEAL_TYPE.
However, based on my testing, OnTradeTransaction indeed has the limitation.
For example, if inside your OnTradeTransaction you have 5 step to run, if while it is running certain step 3 in OnTradeTransaction and then there is another deal come in, it will continue the step 4 with new deal instead of previous deal. It is rare and only happen when there is deal that happen in same second, but if will become more often, if you are running your EA on multiple symbol on different chart. I saw case that the the deal from different chart overwrite and run the remaining step in OnTradeTransaction. Sound like this event is running on a single thread.
I really hope Metatrader team fix this limitation. If not, this OnTradeTransaction can't usable on a very high trading frequency scenario.
Thanks.
There is nothing to fix. This is how it works and is documented (did you read it ?). Your code has to deal with it.
There is nothing to fix. This is how it works and is documented (did you read it ?). Your code has to deal with it.
Hi Alain,
Thanks for pointing me to read the documentation again. You are right. In the document, it did state the following. Just want to check with you, is there a way that we can increase the queue length ? Thanks!
Transactions queue length comprises 1024 elements. If OnTradeTransaction() handles yet another transaction for too long, the previous ones can be superseded by new transactions in the queue.
Hi Alain,
Thanks for pointing me to read the documentation again. You are right. In the document, it did state the following. Just want to check with you, is there a way that we can increase the queue length ? Thanks!
Transactions queue length comprises 1024 elements. If OnTradeTransaction() handles yet another transaction for too long, the previous ones can be superseded by new transactions in the queue.
No it's hardcoded. However, in my opinion it should be largely enough if your code is optimal.
My remark about the documentation was more headed to the order of incoming events.
All code of one EA instance is executed in one thread.
Yeah, that is my understanding too, but for OnTradeTransaction, it is not per EA instance for one thread.All deal come into the same thread even it is on different instance and different chart.
The sequence of incoming deal is not a problem for me. The issue that I have is the following scenario.
I run 2 EA on 2 chart ( EURUSD and AUDCAD).
in the on OnTradeTransaction, after a order is open, i have 5 step to run.
My issue happen when both EA open a new order ( 1 for EURUSD and 1 for AUDCAD) in the same second.
EURUSD deal is executing the step in OnTradeTransaction till step 3, and then suddenly step 4 is executing with AUDCAD order.
In that case, EURUSD deal is executed till step 3, while AUDCAD deal does not have step1-3 executed, while have step 4-5 executed.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All,
I hit a rare issue in OnTradeTransaction , which I suspect could be a bug.
Basically, what I did is in OnTradeTransaction, I will check the order_state and if the order_state is TRADE_TRANSACTION_DEAL_ADD, then it will print the following
Print("On Trade for Ticket:", lastOrderID, " OrderType: ", EnumToString(trans.order), " PositionType:", EnumToString((ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE)), " TransType:" , EnumToString(trans.order_type), " orderstate:", EnumToString(trans.order_state));
Then I will set the TP and SL on that order.
I actually hit 2 issue.
1. The trans.order is always ORDER_TYPE_BUY. No matter you are buy in, buy out or sell in , sell out order. You can see the 202, 203 and 204 order are all type buy.
2. if there is a few transaction hit in the same second, then the ontradetransaction seems to be does not complete and overwrite by newer transaction. You can see in the following example, order 202 happen first then it overwrite by 203 and then it run the update TP on 204.
If someone know how to fix this, please let me know.
If it is a bug, I hope metatrader team can fix this. Thanks !