Loading page…
Loading page…
Generate compiled Pine v5/v6 strategy scaffolds, audit backtest realism, eliminate repainting, and configure strategy.exit() stops.
Assemble a clean, non-repainting strategy skeleton with realistic fees, date-range filtering, exit logic, and webhook hooks.
1//@version=62strategy(3 "Production Pine v6 Strategy Scaffold",4 overlay = true,5 initial_capital = 10000,6 default_qty_type = strategy.percent_of_equity,7 default_qty_value = 100,8 commission_type = strategy.commission.percent,9 commission_value = 0.05,10 slippage = 2,11 process_orders_on_close = false,12 calc_on_every_tick = false13)14 15// 1. Backtest Window & Risk Inputs16i_start = input.time(timestamp("2024-01-01T00:00:00Z"), "Start Date")17i_end = input.time(timestamp("2026-12-31T23:59:59Z"), "End Date")18inDateWindow = time >= i_start and time <= i_end19i_atrLen = input.int(14, 'ATR Length', minval = 1)20atrVal = ta.atr(i_atrLen)21 22// 2. Replace With Your Non-Repainting Entry Logic23fast = ta.ema(close, 21)24slow = ta.ema(close, 55)25longCond = inDateWindow and ta.crossover(fast, slow)26shortCond = inDateWindow and ta.crossunder(fast, slow)27 28// 3. Execution29if longCond and strategy.position_size <= 030 strategy.entry("Long", strategy.long, alert_message = '{"action":"buy","symbol":"' + syminfo.ticker + '"}')31if shortCond and strategy.position_size >= 032 strategy.entry("Short", strategy.short, alert_message = '{"action":"sell","symbol":"' + syminfo.ticker + '"}')33 34// 4. Risk & Exit Engine35if strategy.position_size > 036 strategy.exit("XL", from_entry = "Long", stop = strategy.position_avg_price - atrVal * 2.0, limit = strategy.position_avg_price + atrVal * 3.0)37if strategy.position_size < 038 strategy.exit("XS", from_entry = "Short", stop = strategy.position_avg_price + atrVal * 2.0, limit = strategy.position_avg_price - atrVal * 3.0)39 40plot(fast, "EMA 21", color = color.new(#2962ff, 0))41plot(slow, "EMA 55", color = color.new(#ff9800, 0))Check every engineering guard your TradingView strategy currently enforces before trusting Strategy Tester equity curves.