burneh
Trading

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.

es_breakout.pinepine v5
1//@version=5
2strategy("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)
8
9lookback = input.int(20, "Breakout lookback")
10upper = ta.highest(high, lookback)[1]
11atr = ta.atr(14)
12
13// act only on a bar that has actually closed — no repainting
14longSignal = ta.crossover(close, upper) and barstate.isconfirmed
15
16if longSignal
17 strategy.entry("long", strategy.long)
18 strategy.exit("bracket", from_entry = "long",
19 stop = close - 2.0 * atr, // stop always attached
20 limit = close + 3.0 * atr) // 2:3 risk / reward
ES · 5m · signalson close only
breakout 5840××
▲ confirmed buy, locked× poked mid-bar, closed below — no order

It 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.

Strategy Tester · ES Breakout5m · 2019–2024
net profit
+58.0%
closed trades
214
profitable
47%
profit factor
1.40
max drawdown
−18.4%
equity curve

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.