I am new to pinescript and wrote this simple script to show me daily, weekly and monthly candle open lines by piecing together information I could find. This works well but I would like to add input options to change the line(s) width and style (dotted, dashed). Seems like an easy task, but somehow I can't figure it out. Could anybody help?
A bit more work but, my next step would be to be able to toggle an option where, after a period ends, the line would extend until it is crossed by price again. If there is an easy way to do this, I would be much grateful for any tips.
Thanks in advance!
//@version=6
indicator("D/W/M Open Lines", overlay=true, max_lines_count=500)
// === Input Options ===
showDaily = input.bool(true, title="Show Daily Open")
showWeekly = input.bool(true, title="Show Weekly Open")
showMonthly = input.bool(false, title="Show Monthly Open")
dailyColor = input.color(color.aqua, "Daily Line Color")
weeklyColor = input.color(color.yellow, "Weekly Line Color")
monthlyColor = input.color(color.fuchsia, "Monthly Line Color")
// === Line Variables ===
var line dailyLine = na
var line weeklyLine = na
var line monthlyLine = na
// === Daily Line Logic ===
dailyOpen = request.security(syminfo.tickerid, "D", open)
dailyTime = request.security(syminfo.tickerid, "D", time)
newDaily = dailyTime != dailyTime[1]
if showDaily
if newDaily
if not na(dailyLine)
line.set_x2(dailyLine, x=dailyTime)
dailyLine := line.new(x1=dailyTime, y1=dailyOpen, x2=time, y2=dailyOpen, color=dailyColor, extend=extend.none, xloc=xloc.bar_time)
else if not na(dailyLine)
line.set_x2(dailyLine, x=time)
// === Weekly Line Logic ===
weeklyOpen = request.security(syminfo.tickerid, "W", open)
weeklyTime = request.security(syminfo.tickerid, "W", time)
newWeekly = weeklyTime != weeklyTime[1]
if showWeekly
if newWeekly
if not na(weeklyLine)
line.set_x2(weeklyLine, x=weeklyTime)
weeklyLine := line.new(x1=weeklyTime, y1=weeklyOpen, x2=time, y2=weeklyOpen, color=weeklyColor, extend=extend.none, xloc=xloc.bar_time)
else if not na(weeklyLine)
line.set_x2(weeklyLine, x=time)
// === Monthly Line Logic ===
monthlyOpen = request.security(syminfo.tickerid, "M", open)
monthlyTime = request.security(syminfo.tickerid, "M", time)
newMonthly = monthlyTime != monthlyTime[1]
if showMonthly
if newMonthly
if not na(monthlyLine)
line.set_x2(monthlyLine, x=monthlyTime)
monthlyLine := line.new(x1=monthlyTime, y1=monthlyOpen, x2=time, y2=monthlyOpen, color=monthlyColor, extend=extend.none, xloc=xloc.bar_time)
else if not na(monthlyLine)
line.set_x2(monthlyLine, x=time)