condition = ta.barssince(ta.rsi(close, 14) > 20) == 1
var flag = false
if ta.ema(close, 50) > ta.ema(close, 200)
flag := true
var theLine = line.new(0, 0, 0, 0)
if flag
line.set_xy1(theLine, bar_index - ta.barssince(condition), ta.valuewhen(condition, close, 0))
line.set_xy2(theLine, bar_index, close)
The code above will plot a line from the close of the latest occurence of the condition to the current close. How do I plot a line for every occurence of the condition to the current close?
EDIT: (Here's visual representation of what I'm trying to convey.)


