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: 6, Answers: 3)
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: 1703)
Answered on January 13, 2019 10:13 am
High Pete.I had to change the code from above as it is missing a statement to take into consideration the start time. It only references end time. Also I needed to adjust the time to work in my local time and then added plot lines as the code above does not include the plot lines you show on your chart.
( at January 23, 2019 6:49 am)

Is that actually CL or did you mean /CL? This is not intended for futures, only stocks. As to the plot lines. I never included those in the chart as the request was for chart labels only. The lines you see on my screenshot were hand drawn and only included to show the labels are displaying the correct value.

( at January 24, 2019 8:12 am)