#property copyright "DREW"
#property link      "joinme@yandex.ru"

extern int MomPeriod = 14;
extern int TF = PERIOD_M30;
extern int nomln = 0;
extern int dDay = 0;

int init()
{
   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   int total,cnt;
   double Step = 0.0045;
   double TProf = 0.0100;
   double MVol = iCustom(NULL,TF,"Momentum of volume",MomPeriod,0,0);
   double MVol500 = iCustom(NULL,TF,"Momentum of volume",MomPeriod,1,0);
   
   nomln++;
   double TrendLineBeginTime = Time[0];
   double LowestPrice = iLow(NULL,PERIOD_W1,0);
   
   if(MVol500 != 0)
   {
      ObjectCreate("AL"+nomln,OBJ_ARROW,0,Time[0],LowestPrice,0,0,0,0);
      ObjectSet("AL"+nomln, OBJPROP_ARROWCODE, 110);
      ObjectSet("AL"+nomln, OBJPROP_COLOR , Blue);
      
      if((OrdersTotal() == 0) && (dDay != Day()))
      {
         OrderSend(Symbol(),OP_BUYSTOP,1,Bid+Step,3,0,Bid+Step+TProf,"",0,0,Aqua);
         OrderSend(Symbol(),OP_SELLSTOP,1,Ask-Step,3,0,Ask-Step-TProf,"",0,0,Orange); 
         dDay = Day();
      }
   }   

   if(OrdersTotal() == 1)
   {
      total = OrdersTotal();
      for(cnt=0;cnt<total;cnt++)
      {  
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);         
         if(OrderType()==OP_BUYSTOP)
         {
            OrderDelete(OrderTicket());
         }
         if(OrderType()==OP_SELLSTOP)
         {
            OrderDelete(OrderTicket());
         }
      }
   }

   return(0);
}


