Time Calculations

 

Hello guys i need to manupilate time based on calculations can i do that like for eg i have today open stick time

datetime dailyopentime;
for ( int i = 0 ; i < 24 ; i++ )
{
   if ( TimeHour(Time[i]) == OpenTime ) //OpenTime can be any integer from 0 to 23
   {
     dailyopentime = iTime(Symbol(), Period_H1, i);
   }
}

now how can i add hours or minutes to the time/variable "dailyopentime"

 

A datetime is the number of seconds since 1st Jan 1970 . . . to add to a datetime you just add the number of seconds you want, so to add an hour add PERIOD_H1 * 60 * 60

Info in the documentation: datetime functions, datetime constants