//@version=6 strategy("Manual plan runner", overlay = true, initial_capital = 10000, pyramiding = 0, default_qty_type = strategy.fixed, default_qty_value = 1, commission_type = strategy.commission.cash_per_order, commission_value = 1, slippage = 1, margin_long = 100, margin_short = 100) decision = input.time(timestamp("01 Jan 2025 21:00 +0000"), "Qualifying close time") side = input.string("Long", "Side", options = ["Long", "Short"]) kind = input.string("Stop", "Entry type", options = ["Stop", "Limit", "Market"]) entryPrice = input.float(66, "Entry reference") stopPrice = input.float(63, "Protective stop") target = input.float(83, "Target") units = input.int(1, "Units", minval = 1) life = input.int(3, "Subsequent entry bars", minval = 1) longSide = side == "Long" valid = longSide ? stopPrice < entryPrice and target > entryPrice : stopPrice > entryPrice and target < entryPrice if not valid runtime.error("Check entry, stop and target order") var bool sent = false var int submitted = na eligible = barstate.isconfirmed and time_close >= decision if eligible and not sent direction = longSide ? strategy.long : strategy.short stopEntry = kind == "Stop" ? entryPrice : na limitEntry = kind == "Limit" ? entryPrice : na strategy.entry("Plan", direction, qty = units, stop = stopEntry, limit = limitEntry) strategy.exit("Bracket", "Plan", stop = stopPrice, limit = target) submitted := bar_index sent := true if sent and strategy.position_size == 0 expired = bar_index - submitted >= life failed = longSide ? close <= stopPrice : close >= stopPrice if expired or failed or strategy.closedtrades > 0 strategy.cancel_all() plot(sent ? entryPrice : na, "Entry reference", color.gray) plot(sent ? stopPrice : na, "Stop", color.red) plot(sent ? target : na, "Target", color.blue)