Pine script 如何使用dayofweek函数

Pine script 如何使用dayofweek函数,pine-script,Pine Script,我试图将代码应用于一周中的某一天,以便在该天设置一个指示器。我可以使用dayofweek函数,还是有更好的方法 last_day = friday plotshape(last_day, style=shape.diamond, location=location.belowbar, color=green, size=size.tiny) 我希望这会在所有的星期五下设置一个形状,但它会在每天下设置一个形状。在v3中,正如您所使用的,需要: plotshape(dayofweek==frid

我试图将代码应用于一周中的某一天,以便在该天设置一个指示器。我可以使用dayofweek函数,还是有更好的方法

last_day = friday

plotshape(last_day, style=shape.diamond, location=location.belowbar, color=green, size=size.tiny)

我希望这会在所有的星期五下设置一个形状,但它会在每天下设置一个形状。

在v3中,正如您所使用的,需要:

plotshape(dayofweek==friday, style=shape.diamond, location=location.belowbar, color=green, size=size.tiny)
请注意,它位于exchange的时区中。

用于Pine脚本v4

我不确定你或其他人是否会觉得这有用,但它可以作为解决这类问题的一种方法

此代码每天打印一条背景线,每周第一天打印另一个背景(使用不同颜色)时除外。它根据时间在烛台上方绘制背景

enableTLa = input(defval=true, type=input.bool, title="Enable Timelines 1D (TLa)")
colorA = input(title="Color TLa", type=input.color, defval=color.white)
enableTLd = input(defval=true, type=input.bool, title="Enable Timelines 1W (TLd)")
colorD = input(title="Color TLd", type=input.color, defval=color.yellow)
transpTL = input(defval = 80, title = "Timelines Transparency")

targetTime0     = timestamp(year, month, dayofmonth, 00, 00, 00) //  1D

timeframeRangeA = timeframe.period == "1" or timeframe.period == "3" or timeframe.period == "5" or timeframe.period == "15" or timeframe.period == "30" or timeframe.period == "45" or timeframe.period == "60"
timeframeRangeD = timeframe.period == "1" or timeframe.period == "3" or timeframe.period == "5" or timeframe.period == "15" or timeframe.period == "30" or timeframe.period == "45" or timeframe.period == "60" or timeframe.period == "120" or timeframe.period == "180" or timeframe.period == "240" or timeframe.period == "D"

// 1W, first day of the week, at first hour
bgcolor(targetTime0 == time and enableTLd and timeframeRangeD and dayofweek == dayofweek.monday ? colorD : na, transp=transpTL, editable=false)
// 1D, day of the week, at first hour
bgcolor(targetTime0 == time and enableTLa and timeframeRangeA and dayofweek != dayofweek.monday ? colorA : na, transp=transpTL, editable=false)
这是1h时间范围内的结果:


如您所见,它不会将背景绘制到未来。

v4上的相同问题如何?我尝试了不同的方法都没有成功。
plotshape(dayofweek==dayofweek.friday,style=shape.diamond,location=location.belowbar,color=color.green,size=size.tiny)