Pine that behaves the same live as it does in the tester.
Most custom Pine looks incredible in the strategy tester and falls apart the moment it's live, because it repaints. We write scripts that only act on closed bars, ship a stop with every entry, and set the costs honestly, so the backtest you approve is the behaviour you actually get.
The strategy, in real Pine.
Costs and slippage set in the header, size as a percent of equity, and a stop that ships with every entry. The one line that matters most is barstate.isconfirmed: nothing acts until the bar has actually closed.
1//@version=52strategy("ES Breakout", overlay = true,3 default_qty_type = strategy.percent_of_equity,4 default_qty_value = 10,5 commission_type = strategy.commission.cash_per_contract,6 commission_value = 2.10,7 slippage = 1)89lookback = input.int(20, "Breakout lookback")10upper = ta.highest(high, lookback)[1]11atr = ta.atr(14)1213// act only on a bar that has actually closed — no repainting14longSignal = ta.crossover(close, upper) and barstate.isconfirmed1516if longSignal17 strategy.entry("long", strategy.long)18 strategy.exit("bracket", from_entry = "long",19 stop = close - 2.0 * atr, // stop always attached20 limit = close + 3.0 * atr) // 2:3 risk / rewardIt doesn't repaint.
A repainting script fires the moment price pokes above the line, mid-bar, then the bar closes back below and the signal was never there. We gate on the closed bar, so the arrow you see in the tester is the arrow you'd have got live.
The tester, with costs in.
TradingView's own strategy tester, run with the commission and slippage set in the header, so the equity curve isn't quietly flattering itself.
A green tester is a hypothesis, not a promise.
The Pine strategy tester is a backtest, and every caveat on the backtesting page applies here too. We write the script well, gate it to closed bars so it behaves the same live, and set the costs honestly. The edge still has to be real. When it's ready, the same alert wires straight to a verified webhook and becomes a risk-checked broker order.
Pine that behaves the same live as it does in the tester.
Non-repainting by rule, a stop on every entry, honest costs in the tester, and alerts wired to a verified webhook. The backtest you approve is the behaviour you get.