简体   繁体   中英

How to get the highest high and the lowest low of specific timeframe in pinescript

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.

//@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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM