MT4 pre-183

 
Hi,

My test progrram adds orders ok, but sometimes these orders in the trades window are not updated as the prices move.

can anyone suggest how to resolve this?

many thanks
 
I beleive the developers are dealing with the problem.

Closeprice gets updated when the order is modified.
Here is a workaround which updates closeprice if the current price moves further than 5 points from it in symbols that are known to fail to show the correct price and alerts if the price is not updated in unknown symbols

    int cnt, total = OrdersTotal();
    int SafeStopLoss = 500;

    for (cnt = total - 1; cnt >= 0; cnt--)
    {
        if (!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
        {
            Print("OrderSelect() failed: ", GetLastError());
            continue;
        }

        if (OrderSymbol() != Symbol())
        {
            continue;
        }

        if (Symbol() == "GBPJPYm" || 
            Symbol() == "CHFJPYm" || 
            Symbol() == "AUDCADm" || 
            Symbol() == "EURCADm" || 
            Symbol() == "EURJPYm" || 
            Symbol() == "EURGBPm")
        {
            double sl = 0.;
    
            if (OrderType() == OP_BUY)
            {
                if (MathAbs(Bid - OrderClosePrice()) > 5 * Point)
                   sl = Ask - SafeStopLoss * Point;
            }
            else if (OrderType() == OP_SELL)
            {
                if (MathAbs(Ask - OrderClosePrice()) > 5 * Point)
                    sl = Bid + SafeStopLoss * Point;
            }
    
            if (sl != 0)
            {
                if (!OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0))
                    Print("OrderModify() failed: ", GetLastError());
            }
        }
        else
        {
            if (OrderType() == OP_BUY)
            {
                if (Bid != OrderClosePrice())
                    Alert(OrderSymbol(), ": Incorrect buy order close price ", OrderClosePrice(), ", bid ", Bid);
            }
            else if (OrderType() == OP_SELL)
            {
                if (Ask != OrderClosePrice())
                    Alert(OrderSymbol(), ": Incorrect sell order close price ", OrderClosePrice(), ", ask ", Ask);
            }
        }
    }



Note that the code uses big stop loss values to modify the order. The workaround is used in expert that doesn't set any stoplosses.
The workaround can be adopted for concrete expert by using real stop loss or take profit values +- min stoploss.

 
Hi,

Many thanks for that workround

As a seperate issue - do you know if the Interbankfx demo server has problems maintaining it signal, we seem to get regular drop outs of the data feed.

rgds
 
I wouldn't blame any particular server.

It seems like all the dealers've been showing the same problem with the connection on both real and demo accounts.

Try the latest (today's) build. It's available at the same url https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe?utm_campaign=MQL5.community
Reason: