My question is, after a trend breakout, I want to end the trend line regardless of whether the breakout is confirmed or not. How can I do that?”
breakout(tl.Trendline this, float pType) =>var bool hasCrossed = false
var bool nextBarConfirmed = false
if ta.change(this.lines.startline.get_y1())
hasCrossed := false
this.drawTrendline(not hasCrossed)
confirmation = not hasCrossed and (input_repaint ? not hasCrossed : barstate.isconfirmed)
if (pType == pl ? (input_override and input_useSrc ? input_source : close) < this.lines.trendline.get_y2() : (input_override and input_useSrc ? input_source : close) > this.lines.trendline.get_y2()) and confirmation
nextBarConfirmed := (pType == pl ? (input_override and input_useSrc ? input_source[1] : close[1]) < this.lines.trendline.get_y2() : (input_override and input_useSrc ? input_source[1] : close[1]) > this.lines.trendline.get_y2())
if nextBarConfirmed
hasCrossed := true
this.lines.startline.set_xy2(this.lines.trendline.get_x2(), this.lines.trendline.get_y2())
this.lines.trendline.set_xy2(na, na)
this.lines.startline.copy()
hasCrossed
Nurettin Özdemir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.