Parabolic1
Parabolic1

Reputation: 17

Highlighting an Hourly Candle

I'd like to highlight the 16:00 bar on the 1H timeframe everyday but can't seem to get the code right. The only piece I'm missing is the code to pinpoint the bar and time_close doesn't seem to be working for this. Thank you in advance for any guidance.

Update: This code seems to be working for the most part but randomly skips some bars, ie. doesn't highlight them. I'm not sure why. The code is as follows:

study("1600 bars", overlay=true)
t = time(timeframe.period, "1600-1700")

fourUp = t and close > open
fourDown = t and close < open

barcolor(fourUp ? color.white : na, title="Four Up")
barcolor(fourDown ? color.yellow : na, title="Four Down")

Upvotes: 0

Views: 581

Answers (1)

vitruvius
vitruvius

Reputation: 21159

time() by default will exclude weekends. But you can specify which days of the week you want to work with. Just add :1234567 to your session string if you want your script to work seven days.

//@version=4
study("1600 bars", overlay=true)
t = time(timeframe.period, "1600-1700:1234567")

fourUp = t and close > open
fourDown = t and close < open

barcolor(fourUp ? color.white : na, title="Four Up")
barcolor(fourDown ? color.yellow : na, title="Four Down")

Upvotes: 1

Related Questions