Your code is mixing history data and open orders (pending). Check the documentation please.
What you are trying to achieve is not clear, and I doubt any one will read an article to understand it.
Thanks for the answer.
The code of this article is far from optimal, but it works I suppose. So your idea to replace "deals" with "orders" seems correct (as far as I understand your goal). But you have to do it the right way.
void OnTrade() { // 24 hours back. datetime dtStart=TimeCurrent()-60*60*24; // 24 hours front (in case if you live in GMT-<hours>) datetime dtEnd=TimeCurrent()+60*60*24; // Select history from last 24 hours. if(HistorySelect(dtStart,dtEnd)) { // Go through all deals (from oldest to newest). for(int i=0;i<HistoryOrdersTotal();i++) { // Get deal ticket. ulong ticket=HistoryOrderGetTicket(i); }
You probably have to check the documentation more carefully.
The code of this article is far from optimal, but it works I suppose. So your idea to replace "deals" with "orders" seems correct (as far as I understand your goal). But you have to do it the right way.
You probably have to check the documentation more carefully.
thank you, angevoyageur.
i am checking the documentation more carefully, getting the "history" part out of the code so i can try to only check orders that have been sent at the time, like "now";
ill try to print orders tickets so i can check if they are really "unique" ID's for each order, and from there on, ill try to filter out orders withn the same ID / ticket.
thanks
edit: if you can be of further help, do you think it'd be useful for me to check for the state of the order? as in:
go thru all orders / pending (not history) , check if any of them has already been placed (ORDER_STATE_PLACED), if so, do not send it to the socket, if not, then send it. ?
OR
go thru all orders / pending (not history) , check if any of them has already been placed (ticket), if so, do not send it to the socket, if not, then send it. ?
like:
void OnTrade() { for(int i=0;i<OrdersTotal();i++) { // Get deal ticket. ulong ticket=OrderGetTicket(i); if(OrderGetInteger(ticket)!=i) { send order to socket connector } } }
- 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 there all,
i recently started using this code here https://www.mql5.com/en/articles/344 to route orders out of MT5 using a socket bridge, and i wanted to route ORDERS, not DEALS, so there is no need to wait for the Orders to become Deals after execution (dont want to get slipped by the delay).
im using the server EA of the article above to route out orders that are being sent by MT.
i found that i could change the "deal" strings with "order" most of the time, like this:
but, im getting multiple orders sent because of the delay in execution. seems like that when an order is still pending, the EA sees it as a new order and sends it again to the socket connector.
i wanted some kind of ORDER ID that is unique to a pending order / new order so that i could make the EA NOT to sent double orders, even when they are still waiting to be executed, pending.
can anyone help ?
thanks !