Below I have the background color of the third friday of every month and a closing line for every week. I would like to set the closing line only for the third friday. Can anyone point me in the right direction?
//Third Friday background color
study(title="sauce", shorttitle="ss", overlay=true)
c = #c2c2c2
c1 = #aa8a8a
bgColor =
(dayofweek == friday and dayofmonth < 22 and dayofmonth > 14) ? color(c1, 90) :
(dayofweek == friday) ? color(c, 90) :
color(#cbcbcb, 0)
bgcolor(color=bgColor)
//Weekly close
cwl = input(true, title="Previous Closing Weekly Line")
wclose = security(tickerid, 'W', close[1])
wcolor2 = purple
plot(cwl and wclose? wclose :na , title="Weekly_Close",style=circles, color=wcolor2, linewidth=3)
Translated the script to pine v4. The script works only on intraday timeframes due to dayofweek
function behavior.
//@version=4
study(title="sauce", shorttitle="ss", overlay=true)
c = #c2c2c2
c1 = #aa8a8a
bool isThirdFriday = dayofweek == dayofweek.friday and dayofmonth < 22 and dayofmonth > 14
bgColor =
isThirdFriday ? color.new(c1, 70) :
dayofweek == dayofweek.friday ? color.new(c, 90) :
color.new(#cbcbcb, 0)
bgcolor(color=bgColor)
var float thirdFridayClose = na
if not isThirdFriday and nz(isThirdFriday[1])
thirdFridayClose := close[1] // 'open' for daily timeframe
plot(thirdFridayClose)
//@version=4
study(title="Help (sauce)", shorttitle="ss", overlay=true)
c = #c2c2c2
c1 = #aa8a8a
//bgColor = (dayofweek == dayofweek.friday and dayofmonth < 22 and dayofmonth > 14) ? color.new(c1, 90) : (dayofweek == dayofweek.friday) ? color.new(c, 90) : color.new(#cbcbcb, 0)
bgColor = color.white
var wclose = 0.0
tmpWclose = security(syminfo.tickerid, 'W', close[1])
if dayofweek == dayofweek.friday and dayofmonth < 22 and dayofmonth > 14
wclose := tmpWclose
bgColor := color.new(c1, 90)
else
bgColor := color.new(#cbcbcb, 0)
bgcolor(color=bgColor)
//Weekly close
cwl = input(true, title="Previous Closing Weekly Line")
wcolor2 = color.purple
plot(cwl and wclose? wclose : na , title="Weekly_Close", style=plot.style_circles, color=wcolor2, linewidth=3)
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.