- How to trade two accounts at the same time
- Can CUDA of GPU of NVIDIA be used for the backing test of MT4?
- How to quickly to open two order?
You can't send them at exactly the same time. They have to be send one after the other!
Assuming you are using MQL5, use the OrderSend() function (or CTrade class) once for each order request.
You are just fudging the issue and complicate things for the OP! Even asynchronously you cannot send them at exactly the same time. And the same applies to MT4 EAs on separate charts.
You are just fudging the issue and complicate things for the OP! Even asynchronously you cannot send them at exactly the same time. And the same applies to MT4 EAs on separate charts.
Can you send them in the same CPU clock cycle and in the same network packet in 4/5? No, obviously not. Can you send them in less than 1 ms of each other on both platforms? Absolutely. MT is a retail platform not HFT, so for all intensive purposes async is "same time".
I want to send two crossed orders, buy in one asset and sell in other at the same time. How can I do that?
Forum on trading, automated trading systems and testing trading strategies
Automated-Trading, 2018.10.25 18:37
// Example of massive asynchronous trade orders with waiting for a result. #include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006 #include <fxsaber\TradeTransactions\TradeTransactions.mqh> // Access to OnTradeTransaction data anywhere in the program TRADETRANSACTIONS Transactions; // Trading transactions // Open Amount positions as quickly as possible. Return when positions are open. bool OpenPositions( const int Amount = 10 ) { uint RequestID[]; for (int i = ArrayResize(RequestID, Amount) - 1; i >= 0; i--) { const string Symb = SymbolName(i, true); RequestID[i] = OrderSendAsync(Symb, OP_BUY, 1, SymbolInfoDouble(Symb, SYMBOL_ASK), 100, 0, 0); // Send asynchronous order } return(Transactions.Waiting(RequestID)); // Wait for a server response to all asynchronous orders } // Close everything as quickly as possible. Return when the action is confirmed. bool CloseAll() { uint RequestID[]; for (int i = ArrayResize(RequestID, OrdersTotal()) - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS)) // Send asynchronous order RequestID[i] = (OrderType() <= OP_SELL) ? OrderCloseAsync(OrderTicket(), OrderLots(), OrderClosePrice(), 100) : OrderDeleteAsync(OrderTicket()); return(Transactions.Waiting(RequestID)); // Wait for a server response to all asynchronous orders } void OnStart() { if (OpenPositions()) Print(CloseAll()); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use