if printedtp2 == 0 and extreme_tp2_dist < extreme_tp1_dist keys.push(line.new(bar_index[1], tp2, bar_index, tp2, color = lvlCol, width = 2)) printedtp2 := 1
if printedtp3 == 0 and extreme_tp3_dist < extreme_tp2_dist keys.push(line.new(bar_index[1], tp3, bar_index, tp3, color = lvlCol, width = 2)) printedtp3 := 1
if printedtp4 == 0 and extreme_tp4_dist < extreme_tp3_dist keys.push(line.new(bar_index[1], tp4, bar_index, tp4, color = lvlCol, width = 2)) printedtp4 := 1
if printedtp5 == 0 and extreme_tp5_dist < extreme_tp4_dist keys.push(line.new(bar_index[1], tp5, bar_index, tp5, color = lvlCol, width = 2)) printedtp5 := 1
if printedtp6 == 0 and extreme_tp6_dist < extreme_tp5_dist keys.push(line.new(bar_index[1], tp6, bar_index, tp6, color = lvlCol, width = 2)) printedtp6 := 1
if printedtp7 == 0 and extreme_tp7_dist < extreme_tp6_dist keys.push(line.new(bar_index[1], tp7, bar_index, tp7, color = lvlCol, width = 2)) printedtp7 := 1
if keys.size() > 0 aSZ = keys.size() for i = aSZ - 1 to 0 keys.get(i).set_x2(bar_index)
// Alert when SuperTrend changes direction alertcondition(ta.cross(trendDirection, 0), title="SuperTrend Direction Change", message="SuperTrend has changed direction")
// Alert when each TP line is drawn alertcondition(printedtp1 == 1, title="TP1 Line Drawn", message="TP1 line has been drawn") alertcondition(printedtp2 == 1, title="TP2 Line Drawn", message="TP2 line has been drawn") alertcondition(printedtp3 == 1, title="TP3 Line Drawn", message="TP3 line has been drawn") alertcondition(printedtp4 == 1, title="TP4 Line Drawn", message="TP4 line has been drawn") alertcondition(printedtp5 == 1, title="TP5 Line Drawn", message="TP5 line has been drawn") alertcondition(printedtp6 == 1, title="TP6 Line Drawn", message="TP6 line has been drawn") alertcondition(printedtp7 == 1, title="TP7 Line Drawn", message="TP7 line has been drawn")
// Alert for crossing under RSI alertcondition(tp, title="Take-Profit Condition", message="Take-Profit condition met")