0
votes

I am currently stuck in pine script, trying to get the highest high and lowest low of specific timeframe, lets say 0000 to 0400 , of the current day

pdh = security(tickerid, 'D', high)
pdl = security(tickerid, 'D', low)

This here gets us the highest high and lowest low of this current day. Note this is with pine script V4.

1
Need more info. You have intraday bar on the chart (like 1-min) and you want to get max/min of 4 first bars in a day? I can't get why you request daily resolution via security. - Michel_T.
So it would be in the hourly timeframe, but the first 4 bars of the day according to my timezone UTC-5, and yeah i need to get those lines on the hourly timeframe but see them even when i switch timeframes thats why i used security - Shyzu
Maybe I'm missing something, but why is your timezone is important? Usually it's about symbol's session first bars. Or you want something different, like for example a symbol is traded 1700-1700 in London time, but you want get the values first 4 bars in your timezone, so it'd be 0000-0400 (or maybe 1700-2100?) in your timezone? - Michel_T.
yeah it would be 0000-0400 in my timezone , or 0600-1000 on london's time, yeah the goal is to be able to target certain candles by time , or high and low according to time - Shyzu
gave an answer below. It's only for highest, but I think you'll managed to implement lowest. - Michel_T.

1 Answers

0
votes
//@version=4
study("Highest of first 4 bars in timezone GMT-5, different from tz of symbol")
t = timestamp("GMT-5", year, month, dayofmonth, hour, minute, second)
highest = -1.0

if hour(t) > 4
    highest := nz(highest[1], -1)
else
    for i = 0 to 1000
        if na(t[i]) or hour(t[i]) > 4
            break
        highest := max(highest, high[i])

plot(highest)

I think it should be looking similar to the code above. Maybe it works not exactly as I expect (I didn't debug nor test it), but I suppose that it'll be enough to implement required features by your own.