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
I have seen the picture. Everything is clear for the stock exchange (with a limit order).
For forex and market orders you are missing the point. Everything is clear.
It's the same with a market order (on the Exchange)
Added by
If we send a market order, then when we receive the ticket, we go to the history with it and
we go to the history and see what happened to it. You can also look at OnTradeTransaction
TRADE_TRANSACTION_HISTORY_ADD
What about "if OrderSend returned the ticket, it's executed"?
Should we run to history after all, or wait for events? Well that's what this thread is about!!!
Correct. What didn't I say in the "box office"?
I even posted an EA (for the Exchange) as an example
Yes, all in all, it's not very on-topic ) But thanks for the input.
It's about that "synchronous" OrderSend ends before the EA sees its impact on the account (no trade in history and no change in position).
And to work properly, we have to come up with crutches in the form of waiting for an event (a very handy feature! But not in this case) or searching the history (also with waiting).
Indeed, there is a problem for FOREX (I ran the same Expert Advisor on FOREX)
But in asynchronous mode (FOREX) it works fine
Of course, everyone will get the message. But they won't know that someone hasn't received the same message a beat earlier and hasn't triggered a new order-send.
New idea.
Write an EA synchroniser. Once OrderSend is made, data is sent to this EA and waits for it to respond.
Although, the difference with the slip variant is the same eggs. All in all, your variant is optimal, unfortunately.
Same with a market order (on the Exchange)
Added
If a market order is sent, once we receive the ticket, we go with it to the history and
see what happened to it.
OrderSend() is an absolutely synchronous function - if a ticket is received, everything is executed.
Below is an example
Added, and here are the logs
https://www.mql5.com/ru/forum/38456/page85#comment_2888263
Thank you for the link. But my question was a little different. Rather, it was not a question but an argument in favor of checking the order state on the spot without waiting for OnTrade() event to be processed.
You must not have looked at the code of the example.
{
if(order_ticket>0)
{
if(OrderSelect(order_ticket))
{
RemoveOrderSyncMode(order_ticket);
}
else
{
Print(__FUNCTION__," Order not select! Ticket = ",order_ticket);
}
}
}
The deletion of the order in sync mode (OrderSend()) should have been after the response from
SendOrserSyncModefunction, but it didn't happen.
2016.10.14 02:18:20.292 Trades'3941932': failed cancel order #102956267 buy limit 1.00 GBPUSD at 1.22374 [Invalid request]
Here is where the error lies. According to the documentation, if we have received a ticket, the order has been placed in the trading system,
But it (in FOREX) is not done, and the deletion occurred in the body of theRemoveOrderAsyncMode function, i.e.
after receiving a message in OnTradeTransaction
Added
To answer the question of the top-starter, after sending an order using the OrderSend(),
the order can be handled after receiving the event in OntradeTransaction (OnTrade).
It seems that the developers will fix the problem.
Added
Now I looked at FORTS - this problem is also there
2016.10.17 18:45:19.081 Trades '1007932': accepted buy limit 1.00 GAZR-12.16 at 12847
2016.10.17 18:45:19.081 Trades '1007932': buy limit 1.00 GAZR-12.16 at 12847 placed for execution
2016.10.17 18:45:19.091 Trades '1007932': order #52178167 buy limit 1.00 / 1.00 GAZR-12.16 at 12847 done in 17.440 ms
2016.10.17 18:45:19.091 Trades '1007932': failed cancel order #52178167 buy limit 1.00 GAZR-12.16 at 12847.00000 [Invalid request]
2016.10.17 18:45:19.091 Trades '1007932': cancel order #52178167 buy limit 1.00 GAZR-12.16 at 12847
2016.10.17 18:45:19.098 Trades '1007932': accepted cancel order #52178167 buy limit 1.00 GAZR-12.16 at 12847
2016.10.17 18:45:19.099 Trades '1007932': cancel order #52178167 buy limit 1.00 GAZR-12.16 at 12847 placed for execution in 7.215 ms
2016.10.17 18:45:19.074 TestOrders (GAZR-12.16,M1) OnChartEvent Send Order Sync mode
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) SendOrderSyncMode Order sent in sync mode
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) RemoveOrderSyncMode Order not sent (remove) in sync mode.
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_ORDER_ADD
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_REQUEST
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_ORDER_UPDATE
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) OnTradeTransaction Order update state = ORDER_STATE_REQUEST_ADD
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_REQUEST
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_ORDER_UPDATE
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) OnTradeTransaction Order update state = ORDER_STATE_PLACED
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) OnTradeTransaction Order plased done. Ticket = 52178167
2016.10.17 18:45:19.091 TestOrders (GAZR-12.16,M1) RemoveOrderAsyncMode Order sent (remove) in async mode
2016.10.17 18:45:19.098 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_ORDER_UPDATE
2016.10.17 18:45:19.098 TestOrders (GAZR-12.16,M1) OnTradeTransaction Order update state = ORDER_STATE_REQUEST_CANCEL
2016.10.17 18:45:19.099 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_REQUEST
2016.10.17 18:45:19.099 TestOrders (GAZR-12.16,M1) OnTradeTransaction Order get ticket done. Ticket = 52178167
2016.10.17 18:45:19.099 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_ORDER_UPDATE
2016.10.17 18:45:19.099 TestOrders (GAZR-12.16,M1) OnTradeTransaction Order update state = ORDER_STATE_REQUEST_CANCEL
2016.10.17 18:45:19.108 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_REQUEST
2016.10.17 18:45:19.108 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_ORDER_DELETE
2016.10.17 18:45:19.108 TestOrders (GAZR-12.16,M1) OnTradeTransaction Transaction type: TRADE_TRANSACTION_HISTORY_ADD
2016.10.17 18:45:19.108 TestOrders (GAZR-12.16,M1) OnTradeTransaction Order remove done. Ticket = 52178167
To answer the question of the top-trader, after sending an order using the OrderSend(),
you can operate with the order after receiving the event in OntradeTransaction (OnTrade)
In the case of two EAs on the same symbol?
Yes, two EAs on the same symbol.
{
ENUM_TRADE_REQUEST_ACTIONS action; // Тип выполняемого действия
ulong magic; // Штамп эксперта (идентификатор magic number)
ulong order; // Тикет ордера
string symbol; // Имя торгового инструмента
double volume; // Запрашиваемый объем сделки в лотах
double price; // Цена
double stoplimit; // Уровень StopLimit ордера
double sl; // Уровень Stop Loss ордера
double tp; // Уровень Take Profit ордера
ulong deviation; // Максимально приемлемое отклонение от запрашиваемой цены
ENUM_ORDER_TYPE type; // Тип ордера
ENUM_ORDER_TYPE_FILLING type_filling; // Тип ордера по исполнению
ENUM_ORDER_TYPE_TIME type_time; // Тип ордера по времени действия
datetime expiration; // Срок истечения ордера (для ордеров типа ORDER_TIME_SPECIFIED)
string comment; // Комментарий к ордеру
ulong position; // Тикет позиции
ulong position_by; // Тикет встречной позиции
};
Weeding out the "wrong" positions, orders and trades.