How to calculate time with periods

 

Hello,

please help me with this. Let's say I'm in H1 and I'd like to calculate the exact time of an intersection
like that

intsections[i].time = TimeCurrent() - ( shift * 3600)

shift is the amount of periods (hours) the last intersection happened. I substract that amount of time in seconds from the current time
This works as long as there's no weekend in between, otherwise it will mess up the calculated time by 2 days. 

Can you help? Thanks a lot. 

 

Perhaps you could try:

intsections[i].time = TimeCurrent() - iTime(NULL,0,shift);
 

Get the seconds into the current bar and add this to the start of the bar you're interested in:

int secondsSinceNewBar = TimeCurrent() - iTime(NULL,0,0);
intsections[i].time = iTime(NULL,0,shift) + secondsSinceNewBar;
 
@lippmaje is right. my suggestion was wrong. sorry about that.
Reason: