'How I stop ploting a line when it hits a Candlebody

I try to stop ploting a line when it Hits a Candlebody. Right now it goes all the way through but it should stop to get plot when it hit the Candlebody. I guess the "na" must get changed

plot(enableTP and dir == 1 ? longExitPrice : na, "Long Take Profit", linewidth=2, color=TPcolor, style = plot.style_linebr)

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source