Experts: Hidden TP and SL

 

Hidden TP and SL:

Easy EA for closing positions with profit or loss. All positions of chart's symbol are counted separately.

Author: Tadeusz Kiesner

 
Thank you for the contribution ...
 
void HiddenTPSL()
  {
   bool clo;
   //while(OrdersTotal()>0)
     {
      for(int i=OrdersTotal()-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         {
            if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicID)
            {
               if(OrderType()==OP_BUY)
               {
                 if (Bid>=OrderOpenPrice()+TP*g_Point)
                 {
                  clo=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,clrAqua);
                  Print("Closed PROIT Buy Orders");
                  }
               }   
               if(OrderType()==OP_SELL)
               {
                  if (Ask<=OrderOpenPrice()-TP*g_Point)
                  {
                  clo=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,clrAqua);
                  Print("Closed PROGIT Sell Orders");
                  }
               }
               if(OrderType()==OP_BUY)
               {
                   if (Bid<=OrderOpenPrice()-SL*g_Point)
                  {
                  clo=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,clrAqua);
                  Print("Closed STOP LOSS BUY Orders");
                  }
               }
                if(OrderType()==OP_SELL)
               {
                  if (Ask>=OrderOpenPrice()+SL*g_Point)
                  {
                  clo=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,clrAqua);
                  Print("Closed STOPLOSS SELL Sell Orders");
                  }
               }
                   break;
               
           }       

         }
        }
     }
    
  }    
This simple will do the Job