Time Arithmetic and Input
-
Hi, what I'm trying to do is use the constant ( starttime) to indicate the first bar of 4bars. then I want to use the timestamp values to identify the series of 4 bars starting at start time. I've tried many things but I can't get it right.
1.constant "starttime" is a string
2.convert "starttime" using StringToDate and save into variable
3.modify variable block to shift fwd for each of the 4 hours
another issue entering different time value into the sting changes nothing
-
@jado58 I see you want to fill Hr1 with "Starttime_v" and this variable fill with "Starttime" by user input.
if I understood your logic, you should change block number and first convert string to date and then fill your times variable.and I'm not sure about you formula format!
-

For some reason I cant convert the string to time, it takes on the day but not the hours and minuets
-
I ended up using the custom MQL code block

MqlDateTime str1,str2;
TimeToStruct(StrToTime(starttime),str1);
MqlDateTime hour1;
hour1.day = str1.day;
hour1.hour =str1.hour ;
hour1.min =0 ;
hour1.sec =00 ;
hr1= str1.hour;MqlDateTime hour2;
hour2.hour =str1.hour+1 ;
hour2.min =0 ;
hour2.sec =00 ;
hr2=hour2.hour;MqlDateTime hour3;
hour3.hour =str1.hour+2 ;
hour3.min =0 ;
hour3.sec =00 ;
hr3=hour3.hour;MqlDateTime hour4;
hour4.hour =str1.hour+3 ;
hour4.min =0 ;
hour4.sec =00 ;
hr4=hour4.hour;