Display HL2 for selected duraion.


Category:
0
0

Hi Pete,

This code idea is taken from your previous solutions. I am not getting the correct values if I select the start time 1800- when future opens.

input StartTime = 1800;
input EndTime = 859;
input StartDate= 20190116;
input EndDate = 20190117;
input labelText = ” HL2ForSelectedPeriod “;

def PivotPeriodstart =  SecondsFromTime(StartTime );
def PivotPeriodstartEnd = SecondsTillTime(EndTime  );
def PivotPeriodstartDate = DaysFromDate(StartDate);
def PivotPeriodendDate = DaysTillDate(EndDate);
def startOfPivotPeriod = PivotPeriodstartDate >= 0 and PivotPeriodstart >= 0;
def endOfPivotPeriod = PivotPeriodendDate >= 0 and PivotPeriodstartEnd >= 0;
rec PivotPeriod = if startOfPivotPeriod then yes else if endOfPivotPeriod [1] then no else PivotPeriod[1];
rec trackHighPivotPeriod = if PivotPeriod and !PivotPeriod [1] then high else if PivotPeriod and high > trackHighPivotPeriod [1] then high else trackHighPivotPeriod [1];
rec trackLowPivotPeriod = if PivotPeriod and !PivotPeriod [1] then low else if low > 0 and PivotPeriod and low < trackLowPivotPeriod [1] then low else trackLowPivotPeriod [1];
def HL2ForSelectedPeriod = Round((trackHighPivotPeriod + trackLowPivotPeriod ) / 2, 2);
AddLabel(yes, Concat(labelText, HL2ForSelectedPeriod), Color.magenta);

Thank you,

Shaishav

Marked as spam
Posted by (Questions: 49, Answers: 62)
Asked on January 18, 2020 4:45 pm
73 views
0
Private answer

This code will not be able to do the job you require. The issue is that you have a start time before midnight with an end time after midnight. The functions that are reading the seconds until end time and seconds from start time are not able to handle that cross over at midnight. This requires a customized solution that is quite complex. More so than I have time for when answering questions in the Q&A forum.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 20, 2020 9:19 am