Remix919
Remix919

Reputation: 1

How to draw dashed vertical line and dashed horizontal line on Sunday Open?

I'm trying to figure out how to draw a dashed vertical line on the Sunday Open candle regardless of timeframe used, and also a dashed horizontal line that extends from one vertical line to the next. Any help would be much appreciated, I would think this should be fairly simple, but Pine Script's time documentation is very confusing and severely lacking in examples and has me so confused. Sample chart below of my manually drawn lines.

Sample Chart with Manually Drawn Lines

I've tried several scripts, but pretty much all seem to use the plot function, which doesn't allow you to use dashed lines.

Upvotes: 0

Views: 966

Answers (1)

beeholder
beeholder

Reputation: 1699

//@version=5
indicator("My script", overlay = true, max_lines_count = 500)
isSunday = dayofweek == dayofweek.sunday
sundayOpen = isSunday and not isSunday[1]

var line horLine = na

if sundayOpen
    vertLine = line.new(bar_index, high, bar_index, low, color = color.gray, extend = extend.both, style = line.style_dashed)
    horLine := line.new(bar_index, open, bar_index + 1, open, color = color.red, style = line.style_dashed)
else
    if not na(horLine)
        line.set_x2(horLine, bar_index)

Upvotes: 0

Related Questions