//+------------------------------------------------------------------+
//|                                                         Time.mq4 |
//|                                                           Akhmad |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Akhmad"
#property link      ""
int Different, Start, End;
string CorrectedTime;
string StringTime;// = "17:33:00";
double HighPrice, LowPrice, BidPrice;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   Comment("Waitting for first Tick...");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   Different = TimeCurrent() - TimeLocal();
   StringTime = TimeToStr(TimeCurrent()+10,TIME_SECONDS);
   HighPrice = Bid;
   LowPrice = Bid;
   Main();
//----
   return(0);
  }
//+------------------------------------------------------------------+
void Main()
   {
      while (true)
         {
            CorrectedTime = TimeToStr(TimeLocal() + Different,TIME_SECONDS);
            Comment(CorrectedTime);
            if (CorrectedTime == StringTime) 
               {
                  Start = TimeLocal() + Different;
                  End = Start + 720;
                  Loop(); 
               }                       
            Sleep(1000);
         }
   }
   
void Loop()
   {
      //Start = Start + 2;
      for (;;)
         {
            RefreshRates();
            BidPrice = MarketInfo("GBPUSD",MODE_BID);
            if (HighPrice < BidPrice) HighPrice = BidPrice;
            if (BidPrice < LowPrice) LowPrice = BidPrice; 
            
            Comment("Time1 : ",TimeToStr(Start,TIME_SECONDS)," Created Time","\n","Time2 : ",TimeToStr(TimeCurrent(),TIME_SECONDS)," Server Time","\n"," High = ",HighPrice,"\n"," Low = ",LowPrice);
            /*
            Time1 is Own Time
            Time2 is server Time
            */
            Sleep(1000);
            Start++;
            if (Start == End) break;
         }
    
    }
      