Using pine editor v5, how can I draw a vertical line on the last candle of the day on every friday

48 Views Asked by At

How can I change the following code to draw a vertical line at the end of every Friday instead of drawing a triangle? Is there a more simple code strategy than what I'm using?

//@version=5    
indicator("Friday Vertical Line", overlay=true)

var line fridayLine = na

// Check if it's Friday    
isFriday = dayofweek == dayofweek.friday

// Check if it's the last candle of the day    
isLastCandleOfDay = hour == 16 and minute == 0

// Draw a triangle only on the last candle of the day on Fridays    
plotshape(series=isLastCandleOfDay and isFriday, color=color.orange, style=shape.triangleup, location=location.belowbar, size=size.small)
2

There are 2 best solutions below

3
vitruvius On

Well, you already use isFriday and isLastCandleOfDay in your plotshape() condition.

Use the same expression and call line.new().

if (isLastCandleOfDay and isFriday)
    line.new(bar_index, close, bar_index, close + syminfo.mintick, color=color.orange, extend=extend.both)
0
LMiller_1022 On

‍♀️ the bgcolor command did exactly what I needed it to do.