OrderModify() much slower than manual change of orders

 

Hi there,

when I move a SL or TP manually, it takes less than a second until it´s confirmed and the SL or TP is at its new price. When I do the same by OrderModify(), it takes 5-10x more time. How can this be? In my log I can see, that the function is called only one time, not several times, so this is not where this comes from.

Anyone an idea?

Doerk 

 

How are you checking that it takes 5-10 x longer?

Remember that an EA can only action when there is a new tick.

It may be that your EA has many other calculations to do and is missing ticks? 

 

No no, I am missing nothing. 

The EA is visually based, I simply move a line to a position and this executes OrderModify() for the SL. There I see, that it takes several seconds until the SL line moves. But if I move the SL manually, the order is modified immediately.

An EA always needs a tick to modify an order? Why that? And, if so, isn't there a workaround? It makes no sense at all when I change the SL or TP, actually it makes also no sense anywhere else, it just slows down everything.  

 

A work-around would be to use OnChartEvent and see if the line has moved, then the EA would not wait for a new tick. Your EA should have been coded not to wait for a new tick.

Usually, the EA calculates the SL and TP, so it would make no sense at all for it to check between ticks because the price hasn't changed. Multiple EAs doing unnecessary checks would slow things down.

 

Please forget the line, forget anything visual. I send a value for the SL via OrderModify(), just like that without delaying anything and it takes seconds til the SL moves. I do it manually and it happens immediately. 

 
Sorry, you are contradicting yourself, so I am confused and have no idea what you are doing.
 

Doerk:

No no, I am missing nothing. 

An EA always needs a tick to modify an order? Why that?

And, if so, isn't there a workaround?

  1. Arrogant; anyone can miss things. People try to help you and you get defensive; Especially since you didn't post your code. Anyone can miss things.
  2. Do you run your code in OnTick? Then yes. Because you coded it that way.
  3. A work around was given by GumRai and you ignored it.
 

What I am doing is claiming, that OrderModify() takes much more time until an SL or TP order is moved than the manual move. There is no contradiction in what I am saying, I just said, that you can ignore the visual part, cause it makes no difference if I use a button to move the SL or a line and the graphical stuff is definitive not the problem. Furhtermore, the code where the Ordermodify is sent is also not the problem. I have a log which reports every call and when there are 10 orders to move, I simply can count the calls and see how long it takes, and as it seems, there is only one execution of OrderModify() per tick, and due to the fact, that SLs and TPs are pending orders, this makes no sense at all. 

The code of the order class has more than 3.000 lines, I don´t think that anyone wants to check it entirely and therefore it makes no sense to post it. But here is the snippet:

 

      //+------------------------------------------------------------------+
      //|  Modify order MT4                                                |
      //+------------------------------------------------------------------+
   protected:      
      virtual bool OnModifyOrder (double price, double sl, double tp, datetime expiration)
         {
      //--- Check validity
            if (m_status!=C_ORDER_STATUS_FILLED && m_status!=C_ORDER_STATUS_PENDING)
               return false;
      //--- Modify with given parameters         
            return OrderModify(m_ticket,price,sl, tp, expiration);
         }

 

The orders are moved in a for-loop, and the function needs 5-10 seconds to exit when there are 10 orders, which is too long for my taste. When I am using it in the strategy tester, it´s totally fluidly, which is a further evidence that my code is not the problem. The code works on tick (order), on timer(visual updates) and on chart events (visual interaction) - totally smooth except this. 

 

Here is the log. As one can see, the initial tick happens at 16:49:08, afterwards five orders are modified "within" this tick. The log says, that it takes almost 2 seconds, but the orders on the chart take 5 seconds til I can see the updated SL lines, actually til tick no 21. Anyway, 2 seconds are too much too. 

Log

 

And here is another log. I assumed, that OrderModify() needs a tick per modification. A tick would mean, that the volume is increased. If there are 5 SLs which are moved, it should need 5 ticks and the volume should be increased by 4 in the meanwhile. But the log shows, that the volume is increased only by one point. If MT does not need one tick to update the SL, what could it be else which takes that long? My ping time is<30msecs. 

Log #2

 
@WHRoeder  & GumRai ... sorry, wash´t meant that way absolutely. I appreciate your guys help. I am not a native speaker, so written words could sound different than they were actually meant.
Reason: