Closing in loss....

 

How do I Close in loss? I would like to close in loss (2 pips). The code below closes all order/s instead of 2 pips loss. Please help with the code below. 

for(int Loop2=OrdersTotal()-1;Loop2>=0;Loop2--)
  {
   if(OrderSelect(Loop2,SELECT_BY_POS,MODE_TRADES))
   if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
   {
    bool CloseLoss=false;
    int Type=OrderType();
    double Loss=OrderLots()*20;
    double ask=MarketInfo(Symbol(),MODE_ASK);
    double bid=MarketInfo(Symbol(),MODE_BID);
    switch(Type)
    {
     case OP_BUY:if(OrderProfit()<Loss)CloseLoss=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0,clrBlue);break;

     case OP_SELL:if(Loss>OrderProfit())CloseLoss=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0,clrRed);break;
     //Print("ErrorCode:",GetLastError());  
    }
   }
  }
 
Scalper8:

How do I Close in loss? I would like to close in loss (2 pips). The code below closes all order/s instead of 2 pips loss. Please help with the code below. 

Do not double post!

I have deleted your duplicated topic.

 
Keith Watford #:

Do not double post!

I have deleted your duplicated topic.

The other post is not mt4 related, Its MTS related. I figured out the one for mt4. Please help with mt5 one! 

Reason: