if useTp2 strategy.exit("TP2_Buy", "Buy", qty_percent = useTp3 ? 50 : 100, limit = tradeTp2, stop = tradeSl) if useTp3 strategy.exit("TP3_Buy", "Buy", limit = tradeTp3, stop = tradeSl) if not useTp1 and not useTp2 and not useTp3 strategy.exit("SL_Buy", "Buy", stop = tradeSl) // ═══════════════════════════════════════ // SELL EXECUTION & EXITS // ═══════════════════════════════════════ if sellSignal risk = atrVal * slAtrMult tradeDir := -1 tradeEntry := close tradeSl := close + risk tradeTp1 := close - risk * rr1 tradeTp2 := close - risk * rr2 tradeTp3 := close - risk * rr3 tradeStartBar := bar_index tp1Hit := false tp2Hit := false tp3Hit := false slHit := false strategy.entry("Sell", strategy.short) if useTp1 strategy.exit("TP1_Sell", "Sell", qty_percent = (useTp2 or useTp3) ? 33 : 100, limit = tradeTp1, stop = tradeSl) if useTp2 strategy.exit("TP2_Sell", "Sell", qty_percent = useTp3 ? 50 : 100, limit = tradeTp2, stop = tradeSl) if useTp3 strategy.exit("TP3_Sell", "Sell", limit = tradeTp3, stop = tradeSl) if not useTp1 and not useTp2 and not useTp3 strategy.exit("SL_Sell", "Sell", stop = tradeSl) // ═══════════════════════════════════════ // CREATE OBJECTS (VISUALS) // ═══════════════════════════════════════ if showRisk if (buySignal or sellSignal) line.delete(lineEntry) line.delete(lineSL) line.delete(lineTp1) line.delete(lineTp2) line.delete(lineTp3) label.delete(lbEntry) label.delete(lbSL) label.delete(lbTp1) label.delete(lbTp2) label.delete(lbTp3) box.delete(profitBox) box.delete(lossBox) lineEnd = bar_index + labelOffset labelPos = lineEnd + 2 lineEntry := line.new(bar_index, tradeEntry, lineEnd, tradeEntry, color=color.gray, width=2) lineSL := line.new(bar_index, tradeSl, lineEnd, tradeSl, color=slColor, width=2) lineTp1 := useTp1 ? line.new(bar_index, tradeTp1, lineEnd, tradeTp1, color=tpColor, width=1, style=line.style_dashed) : na lineTp2 := useTp2 ? line.new(bar_index, tradeTp2, lineEnd, tradeTp2, color=tpColor, width=1, style=line.style_dashed) : na lineTp3 := useTp3 ? line.new(bar_index, tradeTp3, lineEnd, tradeTp3, color=tpColor, width=2) : na lbEntry := label.new(labelPos, tradeEntry, 'ENTRY ' + str.tostring(tradeEntry, format.mintick), style = label.style_label_left, color = color.new(color.gray, 30), textcolor = color.white) lbSL := label.new(labelPos, tradeSl, 'SL ' + str.tostring(tradeSl, format.mintick), style = label.style_label_left, color = color.new(slColor, 40), textcolor = color.white) if useTp1 lbTp1 := label.new(labelPos, tradeTp1, 'TP1 ' + str.tostring(tradeTp1, format.mintick), style = label.style_label_left, color = color.new(tpColor, 40), textcolor = color.white) if useTp2 lbTp2 := label.new(labelPos, tradeTp2, 'TP2 ' + str.tostring(tradeTp2, format.mintick), style = label.style_label_left, color = color.new(tpColor, 40), textcolor = color.white) if useTp3 lbTp3 := label.new(labelPos, tradeTp3, 'TP3 ' + str.tostring(tradeTp3, format.mintick), style = label.style_label_left, color = color.new(tpColor, 40), textcolor = color.white) boxTopTarget = useTp3 ? tradeTp3 : (useTp2 ? tradeTp2 : (useTp1 ? tradeTp1 : tradeEntry)) profitTop = tradeDir == 1 ? boxTopTarget : tradeEntry profitBottom = tradeDir == 1 ? tradeEntry : boxTopTarget profitBox := box.new(left = bar_index, top = profitTop, right = lineEnd, bottom = profitBottom, bgcolor = profitFillColor, border_width = 0) lossTop = tradeDir == 1 ? tradeEntry : tradeSl lossBottom = tradeDir == 1 ? tradeSl : tradeEntry
if useTp2 strategy.exit("TP2_Buy", "Buy", qty_percent = useTp3 ? 50… — TRADING SIGNAL FREE — TG.ME
August 14, 2026 23