Download MetaTrader 5

ordersend error trade timeout

To add comments, please log in or register
Add our Twitter channel to friends and follow the news!
gangsta1
1172
gangsta1 2014.01.27 23:54 

Is there any way I can prevent this from happening or to send the order again if it fails?

My EA can place multiple trades and I am not sure if this is causing the issue, the fact I have 10+ terminals running or just poor EA coding on my part.

The EA seems to run into this problem when trying to modify the order (stop loss + take profit):

void SellTrade()
    {

    double SL = Bid + StopLoss*PipValue*Point;
    if (StopLoss == 0) SL = 0;
    double TP = Bid - TakeProfit*PipValue*Point;
    if (TakeProfit == 0) TP = 0;
    int ticket = -1;
    if (true)
    ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, MaxSlippage, 0, 0, ExpertName, MagicNumber, 0, Red);
    else
    ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, MaxSlippage, SL, TP, ExpertName, MagicNumber, 0, Red);
    if (ticket > -1)
    {
        if (true)
        {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
            
    }
    else
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }

}
whroeder1
14544
whroeder1 2014.01.28 00:28  
gangsta1: Is there any way I can prevent this from happening or to send the order again if it fails?
  1. Create a 99.99999% perfect Internet and give your broker a 99.99999% server.
  2. The documents say wait a minute (after connection is reestablished,) look at open order list and find out if the trade has opened or you need to retry.
To add comments, please log in or register