RicardoSantos

[RS]Open Price Levels V1

EXPERIMENTAL: fixed some issues, found some more. doesnt work on unconventional resolutions ex:. 240minutes.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study(title="[RS]Open Price Levels V1", shorttitle="[RS]OPL.V1", overlay=true)
mode = input("week")
hourfix = input(19, title="hourfix(at what time is 00h correct):", minval=0, maxval=23)
openprice = mode == "hour" ? valuewhen(minute == 0, open, 0) :
        mode == "day" ?
            ( isintraday ? valuewhen(hour == hourfix and minute == 0, open, 0) :
            valuewhen(hour == hourfix, open, 0) ) :
        mode == "week" ?
            ( isintraday ? valuewhen(dayofweek == 1 and hour == hourfix and minute == 0, open, 0) :
            valuewhen(dayofweek == 1, open, 0) ) :
        mode == "month" ?
            ( isintraday ? valuewhen(dayofmonth == 1 and hour == hourfix and minute == 0, open, 0) : 
            valuewhen(dayofmonth == 1, open, 0) ) :
        mode == "year" ?
            ( isintraday ? valuewhen(weekofyear == 1 and dayofweek == 1 and hour == hourfix and minute == 0, open, 0) :
            isdaily ? valuewhen(weekofyear == 1 and dayofweek == 1, open, 0) :
                valuewhen(weekofyear == 1, open, 0) ) : na

scolor = openprice != openprice[1] ? na : close >= openprice ? green : maroon
plot(openprice, color=scolor, linewidth=2)