Help with closing orders from my expert - page 2

 

THANKS!!!!!!!!!!!!!!!!!!!

The problem has been solved finally. Thank you both very much really.

 

Abdull1996:

The problem has been solved finally. Thank you both very much really.

OrderSend(Symbol(),OP_SELL,Lots,Bid,SlipPage,StopLoss,TakeProfit,"Abdu EA",MagicNumberSell,0,Red);
      Time0=Time[0];
             
      if(OrderSelect(MagicNumberBuy, SELECT_BY_POS,MODE_TRADES)==true)  
      OrderClose(OrderTicket(),Lots,Ask,SlipPageClose,Blue); 
  1. OrderSelect loop not magic number.
  2. for multiple orders and closing (or other charts present,) you MUST COUNT DOWN
            for(cnt=OrdersTotal()-1; cnt>=0;cnt++) if(
               OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)
            && OrderSymbol()     ==Symbol() 
            && OrderMagicNumber()==MagicNumber){
                                  if(OrderType()==OP_BUY)   // long position is opened
                                     {
                                        // should it be closed?
                                        
                                     }   
                                  if(OrderType()==OP_SELL) // go to short position
                                     {
                                        // should it be closed?
                                                  
                                     }
            }

  3. You MUST RefreshRates() between any two server calls. Between the OrderSend and each OrderClose
  4. Hedging isn't allowed on US brokers. You MUST close the existing order BEFORE opening the opposite direction. Not to mention you're using twice margin.
Reason: