Open&Close Email Notification Signal Script

 
#property indicator_chart_window
datetime dt;
int temp;
int oldtemp;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   dt = Time[0];
   oldtemp = 0;
   Comment("Alert Indicator v0.4\nDmitry Reznikov"); 
  }
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   temp = 0;
   for (int i=0;i<OrdersTotal();i++)
   {
      OrderSelect(i, SELECT_BY_POS);
      if (OrderSymbol() == Symbol()) temp++;
   }
   if (oldtemp < temp)
   {
      string ordertyp;
      double x=OrderOpenPrice(),y=OrderClosePrice(),pips;
      pips =y - x;
      pips =pips * 10000;
      if(pips < 0)pips = - pips;
            
      if(OrderType()==OP_SELL && OrderOpenPrice() !=0) {
      ordertyp="OPEN SELL";
      SendMail(""+ordertyp+" "+DoubleToStr(OrderLots(),2)+", bal: "+DoubleToStr(AccountBalance(),2)+", eq: "+DoubleToStr(AccountEquity(),2)+", "+OrderComment()+"",
      "Symbol: "+Symbol()+" "+ordertyp+" \n"+
      "Comment: "+OrderComment()+" \n"+ 
      "Ticket#: "+OrderTicket()+" \n"+ 
      "Size: "+DoubleToStr(OrderLots(),2)+" \n"+ 
      "OpenTime: "+TimeToStr(OrderOpenTime())+" \n"+
      "Open: "+DoubleToStr(OrderOpenPrice(),5)+" \n"+
//      "Close: "+DoubleToStr(OrderClosePrice(),5)+" \n"+
//      "Profit: "+DoubleToStr(OrderProfit(),2)+" \n"+
//      "Pips: "+DoubleToStr(pips,1)+" \n\n"+
      "Balance: "+DoubleToStr(AccountBalance(),2)+" \n"+
      "Used Margin: "+DoubleToStr(AccountMargin(),2)+" \n"+
      "Free Margin: "+DoubleToStr(AccountFreeMargin(),2)+" \n"+
      "Equity: "+DoubleToStr(AccountEquity(),2)+" \n"+
      "Open Orders: "+DoubleToStr(OrdersTotal(),0)+" \n\n"+
      "Broker: "+AccountCompany()+" \n"+
      "Name: "+AccountName()+" \n"
      "Server: "+AccountServer()+" \n"
      "Leverage: "+AccountLeverage()+"" );
      }
           
      if(OrderType()==OP_SELL && OrderClosePrice()!=0) {
      ordertyp="CLOSE SELL";
      SendMail(""+ordertyp+" $: "+DoubleToStr(OrderProfit(),2)+", bal: "+DoubleToStr(AccountBalance(),2)+", eq: "+DoubleToStr(AccountEquity(),2)+", mar: "+DoubleToStr(AccountMargin(),2)+", "+OrderComment()+"",
      "Symbol: "+Symbol()+" "+ordertyp+" \n"+
      "Comment: "+OrderComment()+" \n"+ 
      "Ticket#: "+OrderTicket()+" \n"+ 
      "Size: "+DoubleToStr(OrderLots(),2)+" \n"+ 
      "OpenTime: "+TimeToStr(OrderOpenTime())+" \n"+
      "Open: "+DoubleToStr(OrderOpenPrice(),5)+" \n"+
      "Close: "+DoubleToStr(OrderClosePrice(),5)+" \n"+
      "Profit: "+DoubleToStr(OrderProfit(),2)+" \n"+
      "Pips: "+DoubleToStr(pips,1)+" \n\n"+
      "Balance: "+DoubleToStr(AccountBalance(),2)+" \n"+
      "Used Margin: "+DoubleToStr(AccountMargin(),2)+" \n"+
      "Free Margin: "+DoubleToStr(AccountFreeMargin(),2)+" \n"+
      "Equity: "+DoubleToStr(AccountEquity(),2)+" \n"+
      "Open Orders: "+DoubleToStr(OrdersTotal(),0)+" \n\n"+
      "Broker: "+AccountCompany()+" \n"+
      "Leverage: "+AccountLeverage()+"" );
      }      
   }
   oldtemp = temp;
//----
   return(0);
  }
//+------------------------------------------------------------------+
It's work only when open sell send report and i want once close the sell send report.