Page 1 of 1

I'm not sure how to achieve this and I'm a newbie

Posted: Fri Feb 10, 2023 8:15 pm
by Pinescripter
Hi everyone,

I'm currently working on this code to make the bars turn grey at a specific time (from 17:00 to 18:00).

This is the code, and it's not working for me.

Code: Select all

study("Grey Bars")

time = time("1700", "Europe/London")
is_grey = (time >= 1700 and time <= 1800)

barcolor(color = is_grey ? #808080 : an)
Can you please help me with the proper correction/code?

Thank you in advance :zen:

Re: I'm not sure how to achieve this and I'm a newbie

Posted: Sun Feb 12, 2023 6:52 am
by Steve Burman
Hey,

You can use the following

//@version=4
study("Grey Bars")
is_grey = time(timeframe.period, "1700-1800:23456", "Europe/London") this is true if it is between 1700 and 1800 Monday to Friday
barcolor(is_grey ? #808080 : na)

I hope this helps

Re: I'm not sure how to achieve this and I'm a newbie

Posted: Mon Feb 13, 2023 9:04 pm
by Pinescripter
That was very helpful! Thank you so much!

Re: I'm not sure how to achieve this and I'm a newbie

Posted: Mon Feb 20, 2023 1:51 am
by Steve Burman
Glad to hear it has helped