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

extern int ma_1 = 28;
extern int ma_2 = 144;
extern int method = 3;
extern int price = 0;
extern int signal = 14;
extern int s_method = 0;
extern int signal2 = 70;
extern int s_method2 = 0;

int TFbig = PERIOD_H1;
int TF = PERIOD_M5;

int init()
{
   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   double dBuf1_big = iCustom(NULL,TFbig,"[drw-i] YTG-e",ma_1,ma_2,method,price,signal,s_method,signal2,s_method2,0,0);
   double dBuf2_big = iCustom(NULL,TFbig,"[drw-i] YTG-e",ma_1,ma_2,method,price,signal,s_method,signal2,s_method2,1,0);
   double dBuf1 = iCustom(NULL,TF,"[drw-i] YTG-e",ma_1,ma_2,method,price,signal,s_method,signal2,s_method2,0,0);
   double dBuf2 = iCustom(NULL,TF,"[drw-i] YTG-e",ma_1,ma_2,method,price,signal,s_method,signal2,s_method2,1,0);

   
   int total,cnt;
   if((dBuf1 < dBuf2) && (dBuf1_big < dBuf2_big))
   {
      total = OrdersTotal();
      for(cnt=0;cnt<total;cnt++)
      {  
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
         if(OrderType()==OP_SELL)
         {
            OrderClose(OrderTicket(), OrderLots(), Ask, 3, Yellow);
         }
      }
      if(OrdersTotal() == 0) if((Hour() >= 8) && (Hour() <= 19)) OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"",2,0,Blue);
   }
   if((dBuf1 > dBuf2) && (dBuf1_big > dBuf2_big))
   {
      total = OrdersTotal();
      for(cnt=0;cnt<total;cnt++)
      {  
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);         
         if(OrderType()==OP_BUY)
         {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
         }
      }
      if(OrdersTotal() == 0) if((Hour() >= 8) && (Hour() <= 19)) OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,"",1,0,Red);
   }

   return(0);
}






