How to work correctly in MT5 with OrderSend - page 3

 
prostotrader:

Take advantage.

Why are you sending an empty request to the server? It doesn't seem to make sense.
And what will you do in "//see cause result.retcode" if you get say TRADE_RETCODE_TIMEOUT or TRADE_RETCODE_FROZEN ?
 
RickD:
Why are you sending an empty request to the server? It doesn't seem to make sense.
And what will you do in "//see result.retcode" if you get, say, TRADE_RETCODE_TIMEOUT or TRADE_RETCODE_FROZEN ?
I'll hang myself :)
 
Andrey Khatimlianskii:

I support it with both hands. It's as if MQ doesn't want to take responsibility for a ready-made function of sending an order and receiving a response.

My option is also with crutches:

Why not make something similar (not for all occasions, at least the simplest one!) and put it out to SB?

really, what good is the "quick execution" of OrderSend(...) if we in EA have to wait for

for environment updates, in this case history updates... and come up with different algorithms for waiting...

until the history is updated, we won't move on... i.e. this speed is of no use...

 
Denis Sartakov:

really, what good is a "quick" execution of OrderSend(...) if we in EA have to wait for

for an environment update, in this case a history update... and come up with different algorithms for waiting...

until the history is updated, we won't move on... i.e. this speed is of no use...

Probably, it's implemented this way because the terminal can execute OrderSend and OrderSendAsync in parallel, and forced synchronization of history after OrderSend would somehow affect OrderSendAsync, OnTrade, OnTradeTransaction, slowing them down.
 
Andrey Khatimlianskii:
I'm not talking about the built-in language functions, I'm talking about the standard library.
I'm talking specifically about the built-in language functions, that OrderSend could wait for a trade history update internally, but it doesn't. :)
You say that you have a crutch, but it's not so reliable. Give me an example of a good reliable crutch.
I'm saying that maybe you can do without crutches at all. If the developers would change the OrderSend behavior. Make it like in MT4.
Or - or - an alternative option. Add the function OrderSendMT4Style. :)
 

A very simple OrderSend overload is written independently: until OnTrade returns a response, all subsequent OrderSends return false. As soon as the response is received - forced false is cancelled.

This is exactly the solution we need to add to the SB. And we must use it ourselves.

In SB, addbool CTrade::IsHistoryLoad( const string Symb = NULL ) by the same principle.

And no crutches! Both functions can be easily written by yourself.

If you want to achieve the full functionality (not for SB), call OnTick and OnTimer independently in OnTrade at arrival of the corresponding synchronization.

 

What a bunch of crutches they've written... Study behaviour of void OnTradeTransaction() function

/*********************TradeTransaction function*********************/
void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
{
      if(trans.type == TRADE_TRANSACTION_DEAL_ADD)
       {
        if(!PositionSelectByTicket(trans.position))
         {
          //Print("********* закрылась позиция ", trans.position);
           closedPosition(trans);
         }
        if(PositionSelectByTicket(trans.position))
         {
          //Print("********* отккрылась позиция ", ", ", EnumToString(trans.deal_type), ", ", trans.position);
           openedPosition(trans);
         }
       }
       
}/*******************************************************************/

Also handle errors of opening positions and orders.

 
Alexey Viktorov:

What a bunch of crutches they've written... Study behaviour of void OnTradeTransaction() function

Also handle errors of opening positions and orders.

You have read the subject diagonally.
 
fxsaber:
You have read the topic diagonally.

No, only vertically. Only the first letter of each line.

 
Andrey Khatimlianskii:

How will this simple overloading work with 2 EAs on the same instrument?

Unfortunately, only through a crutch - a global variable of the terminal.
Reason: