Premarket High/Low label


Hi Hahn,

Im looking for a chart label that displays the high and low in Premarket hours between 0400-0929 (I’ve searched but could not find it)

Thank you

Marked as spam
Posted by (Questions: 4, Answers: 1)
Asked on January 10, 2019 8:51 pm
Private answer

Here is the code:

input startTime = 400;
input endTime = 929;
def timeUntilClose = SecondsTillTime(endTime);
def timeUntilOpen = SecondsTillTime(startTime);
def targetPeriod = timeUntilClose > 0;
rec targetPeriodHigh = if targetPeriod and !targetPeriod[1] then high else if targetPeriod and high > targetPeriodHigh[1] then high else targetPeriodHigh[1];
rec targetPeriodLow = if targetPeriod and !targetPeriod[1] then low else if targetPeriod and low < targetPeriodLow[1] and low > 0 then low else targetPeriodLow[1];
AddLabel(yes, Concat("Period High: ", targetPeriodHigh), Color.GREEN);
AddLabel(yes, Concat("Period Low: ", targetPeriodLow), Color.RED);

Screenshot below shows the result.

User inputs allows to change the target period. If you try to set the time in a way that spans two dates the code will fail.

Marked as spam
Posted by (Questions: 35, Answers: 1594)
Answered on January 13, 2019 10:13 am