
extern double RefHour = 14;
extern double CloseHour = 9;
extern double TopPriceBuf = 27;
extern double BottomPriceBuf = 23;

extern int dDay = 0;

int init()
{
   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   double SAR = iSAR(NULL,0,0.02,0.2,0);

   if((TimeHour(Time[0]) == 14) && (TimeMinute(Time[0]) >= 55))
   {
      if((Close[1] > Open[1]) && (SAR > Close[0]))
      {
         if(OrdersTotal() == 0) OrderSend(Symbol(),OP_BUY,1,Ask,3,0,Ask+0.0020,"",2,0,Blue);
      }
      
      if((Close[1] < Open[1]) && (SAR < Close[0]))
      {
         if(OrdersTotal() == 0) OrderSend(Symbol(),OP_SELL,1,Bid,3,0,Bid-0.0020,"",1,0,Red);      
      }
   }

   return(0);



















   /*int BarsInADay=24*60/Period();
   int n=MathFloor(BarsInADay*0.7);

   string OpenPos = "EMPTY";

   for(int i=0;i<=100;i++)
   {
      if(TimeHour(Time[i])==RefHour && TimeMinute(Time[i]) >= 50)
      {
      
      Print("!!!!! " + TimeHour(Time[i]));

      int x=MathMax(i-n,0);
      string DateString=TimeDay(Time[i])+"/"+TimeMonth(Time[i]);
      double TrendLineBeginTime=Time[i];
      double TrendLineEndTime=Time[x];

      ObjectCreate(DateString+" RefPrice",OBJ_TREND,0,TrendLineBeginTime,High[i]+0.015,TrendLineBeginTime,High[i]+0.0010);
      ObjectSet(DateString+" RefPrice",OBJPROP_TIME1,TrendLineBeginTime);
      ObjectSet(DateString+" RefPrice",OBJPROP_TIME2,TrendLineBeginTime);
      ObjectSet(DateString+" RefPrice",OBJPROP_PRICE1,High[i]+0.015);
      ObjectSet(DateString+" RefPrice",OBJPROP_PRICE2,High[i]+0.0010);
      ObjectSet(DateString+" RefPrice",OBJPROP_COLOR,Red);
      ObjectSet(DateString+" RefPrice",OBJPROP_WIDTH,2);
      ObjectSet(DateString+" RefPrice",OBJPROP_RAY,0);

      ObjectCreate(DateString+" RefPrice1",OBJ_TREND,0,TrendLineBeginTime,Low[i]-0.015,TrendLineBeginTime,Low[i]-0.0010);
      ObjectSet(DateString+" RefPrice1",OBJPROP_TIME1,TrendLineBeginTime);
      ObjectSet(DateString+" RefPrice1",OBJPROP_TIME2,TrendLineBeginTime);
      ObjectSet(DateString+" RefPrice1",OBJPROP_PRICE1,Low[i]-0.015);
      ObjectSet(DateString+" RefPrice1",OBJPROP_PRICE2,Low[i]-0.0010);
      ObjectSet(DateString+" RefPrice1",OBJPROP_COLOR,Red);
      ObjectSet(DateString+" RefPrice1",OBJPROP_WIDTH,2);
      ObjectSet(DateString+" RefPrice1",OBJPROP_RAY,0);


      //if(dDay != Day())
      //{
         if(Close[i] > Open[i])
         {
            OpenPos = "BUY";
            //if(OrdersTotal() == 0) OrderSend(Symbol(),OP_BUY,1,Ask,3,0,Ask+0.0020,"",2,0,Blue);
            //dDay = Day();
         }

         if(Close[i] < Open[i])
         {
            OpenPos = "SELL";
            //if(OrdersTotal() == 0) OrderSend(Symbol(),OP_SELL,1,Bid,3,0,Bid-0.0020,"",1,0,Red);
            //dDay = Day();
         }
      //}
      }
   }

   
   Print(TimeHour(Time[0]));
   
   if((TimeHour(Time[0]) == RefHour) && (TimeMinute(Time[0]) >= 50))
   {
      Print(OpenPos + " " + TimeHour(Time[0]));
      
      if(dDay != Day())
      {
         if(OpenPos == "BUY")
         {
            if(OrdersTotal() == 0) OrderSend(Symbol(),OP_BUY,1,Ask,3,0,Ask+0.0020,"",2,0,Blue);
            dDay = Day();
         }

         if(OpenPos == "SELL")
         {
            if(OrdersTotal() == 0) OrderSend(Symbol(),OP_SELL,1,Bid,3,0,Bid-0.0020,"",1,0,Red);
            dDay = Day();
         }
      }
   }

   return(0);*/
}


