MQL4 Reference Predefined Variables Time

MQL4 Help as One File:

datetime Time[]

Series array that contains open time of each bar of the current chart. Data like datetime represent time, in seconds, that has passed since 00:00 a.m. of 1 January, 1970.

Series array elements are indexed in the reverse order, i.e., from the last one to the first one. The current bar which is the last in the array is indexed as 0. The oldest bar, the first in the chart, is indexed as Bars-1.

Example:

   for(i=Bars-2; i>=0; i--)
     {
      if(High[i+1] > LastHigh) LastHigh = High[i+1];
      if(Low[i+1] < LastLow)   LastLow  = Low[i+1];
      //----
      if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
        {
         P = (LastHigh + LastLow + Close[i+1])/3;
         R1 = P*2 - LastLow;
         S1 = P*2 - LastHigh;
         R2 = P + LastHigh - LastLow;
         S2 = P - (LastHigh - LastLow);
         R3 = P*2 + LastHigh - LastLow*2;
         S3 = P*2 - (LastHigh*2 - LastLow);
         LastLow  = Open[i];
         LastHigh = Open[i];
        }
      //----
      PBuffer[i]  = P;
      S1Buffer[i] = S1;
      R1Buffer[i] = R1;
      S2Buffer[i] = S2;
      R2Buffer[i] = R2;
      S3Buffer[i] = S3;
      R3Buffer[i] = R3;
     }

See also

iTime()