Kevin ATR Renko Pro — Strategy by kevi0924

By version

Performance Metrics

Description

//version=5// ============================================================// Kevin Trading System — ATR + Renko Pro// Author : Kevin// Version : 3.0// Clean | No-Repaint | Professional// ============================================================//// NON-REPAINTING EXPLANATION (For Reference):// --------------------------------------------// All request.security() calls use source[1] with// lookahead=barmerge.lookahead_on.//// This is the official TradingView recommended technique// for non-repainting higher timeframe / alternative chart data.//// - source[1] = previous CONFIRMED bar data only// - lookahead_on = maps that confirmed data to the// correct bar on the current chart//// Using close[1] + lookahead_on is NOT the same as using// close + lookahead_on (which would be repainting).//// The [1] offset ensures future bar data is never accessed.// Signal fires ONLY after bar close — never intrabar.//// Reference: PineScript v5 User Manual — Repainting section// tradingview.com/pine-script-docs/concepts/repainting//// ============================================================strategy("Kevin ATR Renko Pro", shorttitle="Kevin Pro", overlay=true, pyramiding=0, default_qty_type=strategy.fixed, default_qty_value=1, calc_on_every_tick=false, calc_on_order_fills=true, process_orders_on_close=true, max_bars_back=500, initial_capital=5000, commission_type=strategy.commission.percent, commission_value=0.02, max_lines_count=500)// ============================================================// INPUTS// ============================================================EMA1_length = input.int (2, 'Fast EMA Length', group = 'Renko Settings')EMA2_length = input.int (10, 'Slow EMA Length', group = 'Renko Settings')atrLen = input.int (3, 'Renko ATR Length', group = 'Renko Settings')atrLength = input.int (20, 'ATR Length', group = 'ATR Risk Settings')profitFactor = input.float(2.5, 'TP Factor (x ATR)', group = 'ATR Risk Settings', step = 0.1)i_lxQtyTP1 = input.float(50, 'TP1 Qty %', group = 'ATR Risk Settings')i_lxQtyTP2 = input.float(30, 'TP2 Qty %', group = 'ATR Risk Settings')i_lxQtyTP3 = input.float(20, 'TP3 Qty %', group = 'ATR Risk Settings')showBars = input.bool (true, 'Show Trend Bar Colors', group = 'Display')showLabels = input.bool (true, 'Show Entry Labels', group = 'Display')showTPSL = input.bool (true, 'Show TP / SL Lines', group = 'Display')enableFilter = input.bool (true, 'Enable Date Range', group = 'Backtesting Range')fromDate = input.time (timestamp("01 Jan 2023 00:00 +0300"), 'Start Date', group = 'Backtesting Range')toDate = input.time (timestamp("31 Dec 2099 00:00 +0300"), 'End Date', group = 'Backtesting Range')tradeDateIsAllowed = not enableFilter or (time >= fromDate and time timeframe.multiplier * ( timeframe.isseconds ? 1.0 / 60.0 : timeframe.isminutes ? 1.0 : timeframe.isdaily ? 1440.0 : timeframe.isweekly ? 10080.0 : timeframe.ismonthly ? 43800.0 : na)tfmult = 18my_time = str.tostring(f_resInMinutes() * tfmult)param = ticker.renko(syminfo.tickerid, "ATR", atrLen)// [1] = previous confirmed bar — NEVER current forming barrenko_close = request.security(param, my_time, close[1], lookahead = barmerge.lookahead_on)renko_open = request.security(param, my_time, open[1], lookahead = barmerge.lookahead_on)// ============================================================// SIGNAL — EMA CROSSOVER ON RENKO (Non-Repainting)// Fires only on bar close (calc_on_every_tick = false)// ============================================================emaFast = ta.ema(renko_close, EMA1_length)emaSlow = ta.ema(renko_close, EMA2_length)buy = ta.crossover (emaFast, emaSlow)sell = ta.crossunder(emaFast, emaSlow)// Bar color based on Renko directionrenkoUp = renko_close >= renko_openbcolour = renkoUp ? color.new(color.teal, 0) : color.new(color.red, 20)barcolor(showBars ? bcolour : na, title = 'Trend Bar Color')// ============================================================// ATR LEVELS — TP1, TP2, TP3, SL// ============================================================atrVal = ta.atr(atrLength)var float entryPrice = navar float tp1 = navar float tp2 = navar float tp3 = navar float slLevel = naif buy and tradeDateIsAllowed entryPrice := close tp1 := close + 1.0 * profitFactor * atrVal tp2 := close + 2.0 * profitFactor * atrVal tp3 := close + 3.0 * profitFactor * atrVal slLevel := close - 1.0 * profitFactor * atrValif sell and tradeDateIsAllowed entryPrice := close tp1 := close - 1.0 * profitFactor * atrVal tp2 := close - 2.0 * profitFactor * atrVal tp3 := close - 3.0 * profitFactor * atrVal slLevel := close + 1.0 * profitFactor * atrVal// ============================================================// STRATEGY ENTRIES & EXITS// ============================================================if buy and tradeDateIsAllowed strategy.close('Short') strategy.entry('Long', strategy.long)if sell and tradeDateIsAllowed strategy.close('Long') strategy.entry('Short', strategy.short)if strategy.position_size > 0 and tradeDateIsAllowed strategy.exit('LX_TP1', from_entry = 'Long', qty_percent = i_lxQtyTP1, limit = tp1, stop = slLevel) strategy.exit('LX_TP2', from_entry = 'Long', qty_percent = i_lxQtyTP2, limit = tp2, stop = slLevel) strategy.exit('LX_TP3', from_entry = 'Long', qty_percent = i_lxQtyTP3, limit = tp3, stop = slLevel)if strategy.position_size msg = "Kevin Pro | " + syminfo.ticker + "\n" + "Signal: " + dir + "\n" + "Time: " + str.format_time(time, "yyyy-MM-dd HH:mm", syminfo.timezone) + "\n" + "Entry: " + str.tostring(ep, "#.##") + "\n" + "TP1: " + str.tostring(t1, "#.##") + "\n" + "TP2: " + str.tostring(t2, "#.##") + "\n" + "TP3: " + str.tostring(t3, "#.##") + "\n" + "SL: " + str.tostring(sl, "#.##") + "\n" + "ATR: " + str.tostring(atr, "#.##") msgif buy and tradeDateIsAllowed alert(alertMsg('LONG BUY', close, tp1, tp2, tp3, slLevel, atrVal), alert.freq_once_per_bar_close)if sell and tradeDateIsAllowed alert(alertMsg('SHORT SELL', close, tp1, tp2, tp3, slLevel, atrVal), alert.freq_once_per_bar_close)

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView