Search code examples
plotpine-scriptlinepine-script-v5

Line with breaks plot style not working in pine script


I've this indicator coded in pine script which shows certain daily horizontal levels. But, when the plot style is set to "line with breaks", the vertical line joining the levels are still visible just like plot style "lines". But it works fine when "circles" or "cross" style is selected.

Please help me to fix this issue.

//@version=5

indicator(title="fff", overlay=true)

// Get user input
disableRepaint = input.bool(title ="Disable Repainting?", defval=true)

pdl = request.security(syminfo.tickerid, "D", low[disableRepaint and barstate.isconfirmed ? 0 : 1]) 

pdh = request.security(syminfo.tickerid,"D", high[disableRepaint and barstate.isconfirmed ? 0 : 1])


P1 = (pdh-(pdh-pdl) * 0.756)

P2 = (pdl+(pdh-pdl) * 0.790)



//gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off) //Does not repaint

plot(pdl,style=plot.style_linebr,color=color.gray)

plot(pdh,style=plot.style_linebr,color=color.gray)

plot(P1,style=plot.style_linebr,color=color.white, linewidth=2)

plot(P2,style=plot.style_linebr,color=color.white,linewidth=2)

Solution

  • I don't have access to your code so it's difficult to help But, it could look like this

    plot(P1 == P1[1] ? P1 : na, style=plot.style_linebr,color=color.white, linewidth=2)
    
    plot(P2 == P2[1] ? P2 : na,  style=plot.style_linebr,color=color.white,linewidth=2)