//+------------------------------------------------------------------+
//|                                                   Hide-TP_SL.mq4 |
//|                                                           Madjes |
//|                              http://madjes-trading.blogspot.com/ |
//+------------------------------------------------------------------+
#property copyright "Madjes"
#property link      "http://madjes-trading.blogspot.com/"


extern int TakeProfit = 100;
extern int StopLoss = 100;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----

if (OrdersTotal()>0)
   {
      for (int i=0;i<OrdersTotal();i++)
         { 
            OrderSelect(i, SELECT_BY_POS); 
               {
                  if (OrderType()==OP_BUY)
                     {
                        ObjectCreate("TakeProfit"+OrderTicket(),OBJ_HLINE,0,0,OrderOpenPrice()+TakeProfit*Point);
                        ObjectSet("TakeProfit"+OrderTicket(),OBJPROP_COLOR,Green);
                        ObjectCreate("StopLoss"+OrderTicket(),OBJ_HLINE,0,0,OrderOpenPrice()-StopLoss*Point);
                        if (Bid>=(OrderOpenPrice()+TakeProfit*Point)||Bid<=(OrderOpenPrice()-StopLoss*Point)&&(OrderSymbol()==Symbol()))
                           {
                              ObjectDelete("TakeProfit"+OrderTicket());
                              ObjectDelete("StopLoss"+OrderTicket());
                              OrderClose(OrderTicket(),OrderLots(),Bid,NULL);
                           }
                     }
                  if (OrderType()==OP_SELL)
                     {
                        ObjectCreate("TakeProfit"+OrderTicket(),OBJ_HLINE,0,0,OrderOpenPrice()-TakeProfit*Point);
                        ObjectSet("TakeProfit"+OrderTicket(),OBJPROP_COLOR,Green);
                        ObjectCreate("StopLoss"+OrderTicket(),OBJ_HLINE,0,0,OrderOpenPrice()+StopLoss*Point);
                        
                        if (Ask<=(OrderOpenPrice()-TakeProfit*Point)||Ask>=(OrderOpenPrice()+StopLoss*Point)&&(OrderSymbol()==Symbol()))
                           {
                              ObjectDelete("TakeProfit"+OrderTicket());
                              ObjectDelete("StopLoss"+OrderTicket());
                              OrderClose(OrderTicket(),OrderLots(),Ask,NULL);
                           }
                     }
               }
         }
   }    
                         


   
//----
   return(0);
  }
//+------------------------------------------------------------------+