//@version=6 strategy("Workshop 17 Breakout Laboratory", overlay=true, initial_capital=10000, default_qty_type=strategy.fixed, default_qty_value=1, pyramiding=0, commission_type=strategy.commission.percent, commission_value=0.10, slippage=1, process_orders_on_close=false, calc_on_every_tick=false) length = input.int(20, "Prior high bars", minval=2) exitLength = input.int(10, "Exit average bars", minval=2) start = input.time(timestamp("01 Jan 2020 00:00 +0000"), "Start entries") finish = input.time(timestamp("01 Jan 2025 00:00 +0000"), "Stop entries and request exit") if finish <= start runtime.error("Finish must follow start") boundary = ta.highest(high, length)[1] exitLine = ta.sma(close, exitLength) inside = time >= start and time < finish ready = bar_index >= math.max(length, exitLength) enter = (ready and inside and close > boundary and barstate.isconfirmed) leave = close < exitLine or time >= finish if strategy.position_size > 0 and leave strategy.close("Long") else if enter and strategy.position_size == 0 strategy.entry("Long", strategy.long) plot(boundary, "Entry reference", color=color.gray) plot(exitLine, "Exit average", color=color.blue)