简体   繁体   中英

bgcolor for specific date (Pine Script)

I want to give background color for specific date. i am trying below code in pine script version 5.

date = timestamp(2021, 01, 19, 09, 30)
bgcolor(date ? color.new(color.red,70) : na)

As date is true it paints whole chart background to red, can some one help me to contain red color to that specific date only?

i just want it paint bgcolor red only for given date ie "2021, 01, 19, 09, 30". couldn`t find help in manual or elsewhere.

This should do it.

//@version=5
indicator("My Script", overlay=true)

var int     myDate  = input.time(timestamp("13 Jan 2022 09:30 -0500"), 'Choose date/time')
var color   myColor = color.new(color.red,70)

bgcolor(myDate == time ? myColor : na)

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