A breakout signal price is not necessarily its execution price. TradingView's Pine Script strategy emulator normally fills a market order on the next available tick; for historical close-based calculations this is typically the next bar's open. Treating the signal close as the fill can overstate performance.
Worked example
Suppose a breakout closes at 100, the next bar opens at 102, and subsequently closes at 100. With a hypothetical contract value of $10 per price unit, a single contract bought at 102 has an unrealized loss of $20 at 100, before costs. An assumed fill at 100 instead shows no unrealized loss.

Pine Script implementation
Use the preceding 20-bar high as a dynamic threshold, submit a market entry on a confirmed upward crossover, and retain the default next-tick fill policy. Define protective orders in ticks relative to the actual simulated entry.
//@version=6
strategy("Next-tick breakout", overlay=true, pyramiding=0,
process_orders_on_close=false)
level = ta.highest(high[1], 20)
signal = ta.crossover(close, level)
if barstate.isconfirmed and signal and strategy.position_size == 0
strategy.entry("L", strategy.long, qty=1)
strategy.exit("Bracket", "L", loss=16, profit=32)
For a tick size of 0.25, 16 ticks equal four price units and 32 ticks equal eight. A fill at 102 implies nominal stop and target levels of 98 and 110; a fill at 100 implies 96 and 108. The planned distances remain equal but absolute levels differ. The crossover compares both current and prior dynamic thresholds; it is not a crossing of a fixed horizontal level.
Testing and limitations
Test ordinary opens, gaps, commissions and slippage. Compare default execution with process_orders_on_close=true and record signal prices, simulated fills and their differences rather than net profit alone. The latter setting permits simulated closing-tick fills but cannot guarantee real execution at the close. Bar Magnifier can improve certain historical intrabar assumptions but cannot guarantee actual liquidity or execution sequence. Live alerts and external execution systems must independently handle rejected orders, duplicate signals and position reconciliation.
Validate on out-of-sample data and check instrument tick sizes and contract values. This example has not been compiled or backtested here. Stops can slip and trading involves risk of loss.
Reference: Pine Script strategy documentation.
To adapt this free idea to your own rules, contact us about Custom TradingView strategy Development Services.