Download MetaTrader 5

Running more than one EA at a time - page 4

To add comments, please log in or register
whroeder1
15331
whroeder1  
Sneck55: It needs to decrement if it closes an order to match what happens in the pool but not if it doesn't close an order. If it decrements without closing an order it goes into an endless loop.
You can lead a horse to water...
Ian Venner
2584
Ian Venner  
Sneck55:
It needs to decrement if it closes an order to match what happens in the pool but not if it doesn't close an order. If it decrements without closing an order it goes into an endless loop.

If you didn't keep calling OrdersTotal() you wouldnt have that problem. Call the total once. Put it in a int. Use that int in the for loop.

Having said that did you even read my earlier reply ? That entire loop is a complete waste of time. Look at your code. What do you think the value of SellTicket already is ?

         if(SellTicket!=0)
            {
            if(SmallMA>MediumMA)
            {
            for(Counter=0;Counter<=OrdersTotal()-1;Counter++)
               {
               SelectedOrder = OrderSelect(Counter,SELECT_BY_POS);
               if(OrderMagicNumber()==MagicNumber&&OrderSymbol()==Symbol()&&OrderType()==OP_SELL)
                  {
               //   while(IsTradeContextBusy()) Sleep(10);
                  Closed=OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_ASK),Slippage,Red);
                  if(Closed) SellTicket=0;
                  else Alert("Symbol: ",Symbol()," Ticket: ",SellTicket," unable to close sell order(s): sell ma convergence close routine");                  
                  }
            Counter--;               
                }
            }
            }
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI  
And it will consume cpu power over time.
Ian Venner
2584
Ian Venner  

Yes it does, and it is not logical to have already had the neccessary values in the EA then forget them and trawl through the orders pool to retrieve them. That kind of thing only needs to be done as part of reboot recovery.

1234
To add comments, please log in or register