Strategy · Pine Script v5 · On the chart

Snag - No Repaint ES 1m Strategy Candle Bar

by dearvn· code credited to binancash

Snag - No Repaint ES 1m Strategy Candle Bar is an overlay strategy designed for short-term futures trading.

View on GitHub

Repaints

GitHub stars257on the repository
Pine versionv5runs as is
Lines of code617
Settings7inputs
LicenceNone statedfile: MPL-2.0
Last update6 weeks ago11 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

617 lines of Pine Script v5 from no-repain-futures.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

no-repain-futures.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © binancash


//@version=5
strategy("Snag - No Repaint ES 1m Strategy Candle Bar", overlay=true)


minutes = input.int(45, title = "Max minutes to exit", minval = 0, maxval = 240)

stopPer = input(0.05, title='Stop Loss %') / 100 
takePer = input(10, title='Take Profit %') / 100
sideway_pct = input.float(0.08, title = 'Sideway %') / 100

longStop = strategy.position_avg_price * (1 - stopPer)
shortStop = strategy.position_avg_price * (1 + stopPer)
shortTake = strategy.position_avg_price * (1 - takePer)
longTake = strategy.position_avg_price * (1 + takePer)


/////////////////////////////////////////////////////
o_h = math.max(open[3], open[2], open[1])
o_l = math.min(open[3], open[2], open[1])
o_o = open[1]
o_c = open

src(_src)  => 
    Close  = (o_h + o_l + o_o + o_c)/4
    Open  = (o_o + o_c) / 2
    High   = math.max(o_h, math.max(Open, Close))
    Low    = math.min(o_l,  math.min(Open, Close))
    HL2    = math.avg(High, Low) 
    HLC3   = math.avg(High, Low, Close) 
    OHLC4  = math.avg(Open, High, Low, Close)
    Price  = _src == 'close' ? Close : _src == 'open' ? Open : _src == 'high' ? High : _src == 'low' ? Low : _src == 'hl2' ? HL2 : _src == 'hlc3' ? HLC3 : OHLC4  
    Source = math.round(Price / syminfo.mintick) * syminfo.mintick  // PineCoders method for aligning Pine prices with chart instrument prices


source_o = src('open')
source_c = src('close')
source_h = src('high')
source_l = src('low')

//////////////////////////////////
open3m = request.security(symbol=syminfo.tickerid, timeframe="3", expression=open, lookahead=barmerge.lookahead_on)
open5m = request.security(symbol=syminfo.tickerid, timeframe="5", expression=open, lookahead=barmerge.lookahead_on)
open8m = request.security(symbol=syminfo.tickerid, timeframe="8", expression=open, lookahead=barmerge.lookahead_on)
open10m = request.security(symbol=syminfo.tickerid, timeframe="10", expression=open, lookahead=barmerge.lookahead_on)

avg_3m_8 = (open3m[7] + open3m[6] + open3m[5] + open3m[4] + open3m[3] + open3m[2] + open3m[1] + open3m)/8
avg_3m = (open3m[2] + open3m[1] + open3m)/3
//avg_5m = (open5m[10] + open5m[9] + open5m[8] + open5m[7] + open5m[6] + open5m[5] + open5m[4] + open5m[3] + open5m[2] + open5m[1]+ open3m)/10
avg_5m = (open5m[4] + open5m[3] + open5m[2] + open5m[1]+ open3m)/5
//avg_8m = (open8m[10] + open8m[9] + open8m[8] + open8m[7] + open8m[6] + open8m[5] + open8m[4] + open8m[3] + open8m[2] + open8m[1]+ open3m)/10
avg_8m = (open8m[7] + open8m[6] + open8m[5] + open8m[4] + open8m[3] + open8m[2] + open8m[1]+ open3m)/8
//avg_10m = (open10m[10] + open10m[9] + open10m[8] + open10m[7] + open10m[6] + open10m[5] + open10m[4] + open10m[3] + open10m[2] + open10m[1]+ open3m)/10
avg_10m = (open10m[9] + open10m[8] + open10m[7] + open10m[6] + open10m[5] + open10m[4] + open10m[3] + open10m[2] + open10m[1]+ open3m)/10

////////////////////////////////////////////////////
//vwap start
point_lb = 5
point_rb = 5

oh = math.max(open[2], open[1], open)
ol = math.min(open[2], open[1], open)


//plot(close)
point_ph = ta.pivothigh(oh, point_lb, point_rb)
point_pl = ta.pivotlow(ol, point_lb, point_rb)

var float running_ph = na
var float running_pl = na

running_ph := running_ph
running_pl := running_pl

if point_ph
    running_ph := point_ph

if point_pl
    running_pl := point_pl 

plot(running_ph, title = 'R', style = plot.style_circles, linewidth = 1,color=color.red,  offset = -point_rb)
plot(running_ph, title = 'R', style = plot.style_circles, linewidth = 1,color=color.red, offset = 0)

plot(running_pl, title = 'S',  style = plot.style_circles, linewidth = 1,color=color.blue,offset = -point_rb)
plot(running_pl, title = 'S',  style = plot.style_circles, linewidth = 1,color=color.blue, offset = 0)


source = (open[9] + open[8] + open[7] + open[6] + open[5] + open[4] + open[3] + open[2] + open[1] + open)/10


var bool is_strong_buy = false
var bool is_strong_sell = false
if running_ph and ta.crossover(source, running_ph) and barstate.isconfirmed
    is_strong_buy := true
    is_strong_sell := false
if running_pl and ta.crossunder(source, running_ph) and barstate.isconfirmed
    is_strong_buy := false
if running_pl and ta.crossunder(source, running_pl) and barstate.isconfirmed
    is_strong_sell := true
    is_strong_buy := false
if running_pl and ta.crossover(source, running_pl) and barstate.isconfirmed
    is_strong_sell := false

//vwap end

// logic buy sell improve start
src = source
di = (6 - 1.0) / 2.0 + 1.0
c1 = 2 / (di + 1.0)
c2 = 1 - c1
c3 = 3.0 * (0.4 * 0.4 + 0.4 * 0.4 * 0.4)
c4 = -3.0 * (2.0 * 0.4 * 0.4 + 0.4 + 0.4 * 0.4 * 0.4)
c5 = 3.0 * 0.4 + 1.0 + 0.4 * 0.4 * 0.4 + 3.0 * 0.4 * 0.4
var float i1 = na
var float i2 = na
var float i3 = na
var float i4 = na
var float i5 = na
var float i6 = na
i1 := c1 * src + c2 * nz(i1[1])
i2 := c1 * i1 + c2 * nz(i2[1])
i3 := c1 * i2 + c2 * nz(i3[1])
i4 := c1 * i3 + c2 * nz(i4[1])
i5 := c1 * i4 + c2 * nz(i5[1])
i6 := c1 * i5 + c2 * nz(i6[1])

Cto = -0.4 * 0.4 * 0.4 * i6 + c3 * i5 + c4 * i4 + c5 * i3
//bfrC = Cto > nz(Cto[1]) ? raise : Cto < nz(Cto[1]) ? fall : na
//plot(Cto, title='Trend', linewidth=2, style=plot.style_line, color=color.new(color.red, 0), editable=false)
ema3 = ta.ema(source, 3)
//plot(ema3, title='EMA', linewidth=2, style=plot.style_line, color=color.new(color.white, 0))

var bool is_cross_up = false
var bool is_cross_down = false

if ta.crossover(ema3, Cto) and barstate.isconfirmed
    is_cross_up := true
    is_cross_down := false
if ta.crossunder(ema3, Cto) and barstate.isconfirmed
    is_cross_down := true
    is_cross_up := false

//condition Long & Short
long = (source > Cto and o_c[1] < Cto[1] and source > o_c[1] or o_c[1] > Cto[1] and source > o_c[1] and o_c[1] < o_c[2] and source > ema3) and barstate.isconfirmed ? true : false
profit_long = source < o_c[1] and ol < ema3 and o_c[1] > ema3[1] and o_c[2] > ema3[2] and barstate.isconfirmed
//var int trend = 0
    

short = (source < Cto and o_c[1] > Cto[1] and source < o_c[1] or o_c[1] < Cto[1] and source < o_c[1] and o_c[1] > o_c[2] and source < ema3) and barstate.isconfirmed ? true : false
profit_short = source > o_c[1] and oh > ema3 and o_c[1] < ema3[1] and o_c[2] < ema3[2] and barstate.isconfirmed

// logic buy sell improvate end

rsi = ta.rsi(source, 3)


//plot(VWAP, color=color.yellow)


ema48 = ta.wma(source, 48)
ema11 = ta.wma(source, 11)
ema200 = ta.wma(source, 200)




close10 = request.security(symbol=syminfo.tickerid, timeframe="12", expression=close, lookahead=barmerge.lookahead_on)

wma10_11 = ta.wma(close, 4)
wma_10_11 = request.security(symbol=syminfo.tickerid, timeframe="12", expression=wma10_11, lookahead=barmerge.lookahead_on)
//plot(wma_10_11, 'ema10_11', color.blue) 

wma10_48 = ta.wma(close, 9)
wma_10_48 = request.security(symbol=syminfo.tickerid, timeframe="12", expression=wma10_48, lookahead=barmerge.lookahead_on)
//plot(wma_10_48, 'ema10_48', color.yellow) 

close8 = request.security(symbol=syminfo.tickerid, timeframe="11", expression=close, lookahead=barmerge.lookahead_on)

wma8_11 = ta.wma(close, 3)
wma_8_11 = request.security(symbol=syminfo.tickerid, timeframe="11", expression=wma8_11, lookahead=barmerge.lookahead_on)
//plot(wma_10_11, 'ema10_11', color.blue) 

/////////////
var bool cross_up_wma_10 = false
var bool cross_down_wma_10 = false
if ta.crossover(wma_10_11, wma_10_48) and barstate.isconfirmed
    cross_up_wma_10 := true
    cross_down_wma_10 := false
if ta.crossunder(wma_10_11, wma_10_48) and barstate.isconfirmed
    cross_up_wma_10 := false
    cross_down_wma_10 := true

up10m = false

if close10 > wma_10_11
    up10m := true

down8m = false
if close8 < wma_8_11
    down8m := true

////logic volume start
x =  input.float(3.1, title="Factor For Breakout Candle")
red   = #ff848a      //#ff848a // #FA8072 // #323433 // #ff848a
green = #8cffe5      // #8cffe5 // #6DC066 // #80aebd // #8cffe5

// Basic Volume Calcs //
bull =  source>open?volume:0 
bear =  open>source?volume:0


// BEAR Moving Average Calculation
bullma = ta.wma(bull, 14)

// BEAR Moving Average Calculation //
bearma = ta.wma(bear, 14)

// ma dif //
vf_dif = bullma-bearma

// example


vf_absolute = vf_dif > 0 ? vf_dif : vf_dif * (-1)

// Volume Spikes //
var bool gsig = false
var bool rsig = false
if ta.crossover(bull, bullma*x) and barstate.isconfirmed
    gsig := true
    rsig := false
if ta.crossover(bear, bearma*x) and barstate.isconfirmed
    rsig := true
    gsig := false




// Color Calcs //
vdClr = vf_dif > 0 ? true : false
vClr = source>open ? true:false


////logic volume end

// super trend start
cci_period = 28
cci = ta.cci(source, cci_period)
ML = 0

f_supertrend() =>

    Up=hl2 - 3.0 * ta.atr(3)
    Dn=hl2 + 3.0 * ta.atr(3)
    
    TrendUp = 0.0
    TrendUp := cci[1] > ML ? math.max(Up,TrendUp[1]) : Up
    TrendDown = 0.0
    TrendDown := cci[1]< ML ? math.min(Dn,TrendDown[1]) : Dn
    Trend = 0.0
    Trend := cci > ML ? 1: cci < ML ? -1: nz(Trend[1],1)
    Tsl = Trend==1? TrendUp: TrendDown

    Tsl

st_tsl = f_supertrend()

buy= source >= st_tsl
sell= source < st_tsl
buy1= ta.barssince(buy)
sell1 = ta.barssince(sell)

buy_trend = buy1[1] > sell1[1] ? true : false

buy2= ta.barssince(sell)
sell2 = ta.barssince(buy)
sell_trend = buy2[1] > sell2[1] ? true : false
var bool is_buy = false
var bool is_sell = false
if sell_trend
    is_sell := true
    is_buy := false
if buy_trend
    is_sell := false
    is_buy := true
// super trend end

// ema cross start

oc = math.abs(open[1]-source[1])
hl = math.abs(o_h[1]-o_l[1])
ochl = (oc-hl)/hl
ll = (o_l[1]-o_l[2])/o_l[2]
crossUpWMA11 = ta.crossover(ema11, ema48) and barstate.isconfirmed
crossDownWMA11 = ta.crossunder(ema11, ema48) and barstate.isconfirmed
var bool crossup11_48 = false
var bool crossdown11_48 = false
var int cnt_out_up = 0
if crossUpWMA11
    crossup11_48 := true
    crossdown11_48 := false
    cnt_out_up := 0
if crossDownWMA11
    crossup11_48 := false
    crossdown11_48 := true
    cnt_out_up := 0
is_br = o_o[2] < o_c[2] and open[1] < o_c[1] and o_c < open and o_c[2] < o_c[1] and o_c[1] > o_c and ochl < 0.3 and (o_l[3] < o_l[2] and o_l[2] < o_l[1])
if is_br
    cnt_out_up := cnt_out_up + 1

is_out_up = false
if cnt_out_up>2
    is_out_up := true
    cnt_out_up := 0

// ema cross end 


// trend strong start 
wma13 = ta.wma(o_c, 13)
plot(wma13, title="WMA13", color=color.blue)

wma48 = ta.wma(o_c, 48)
plot(wma48, title="WMA48", color=color.yellow)

wma200 = ta.wma(o_c, 200)
plot(wma200, title="WMA200", color=color.white)

crossUpWMA13 = ta.crossover(o_c, wma13) and barstate.isconfirmed
crossDownWMA13 = ta.crossunder(o_c, wma13) and barstate.isconfirmed
crossUpWMA48 = ta.crossover(o_c, wma48) and barstate.isconfirmed
crossDownWMA48 = ta.crossunder(o_c, wma48) and barstate.isconfirmed
crossUpWMA200 = ta.crossover(o_c, wma200) and barstate.isconfirmed
crossDownWMA200 = ta.crossunder(o_c, wma200) and barstate.isconfirmed

crossUpWMA13_48 = ta.crossover(wma13, wma48) and barstate.isconfirmed
crossDownWMA13_48 = ta.crossunder(wma13, wma48) and barstate.isconfirmed
crossUpWMA48_200 = ta.crossover(wma48, wma200) and barstate.isconfirmed
crossDownWMA48_200 = ta.crossunder(wma48, wma200) and barstate.isconfirmed

var price_wmacrossup_arr = array.new_float()
var price_wmacrossdown_arr = array.new_float()

if crossUpWMA48_200
    price_wmacrossdown_arr := array.new_float()
    array.push(price_wmacrossup_arr, o_c)
else if crossDownWMA48_200
    price_wmacrossup_arr := array.new_float()
    array.push(price_wmacrossdown_arr, o_c)
        
var bool isUpTrend = false
var bool isDownTrend = false

if crossUpWMA13 and isUpTrend == false
    isUpTrend := true
    isDownTrend := false
else if crossUpWMA48 and isUpTrend == false
    isUpTrend := true
    isDownTrend := false
else if crossUpWMA200 and isUpTrend == false
    isUpTrend := true
    isDownTrend := false

if crossDownWMA13 and isDownTrend == false
    isUpTrend := false
    isDownTrend := true
else if crossDownWMA48 and isDownTrend == false
    isUpTrend := false
    isDownTrend := true
else if crossDownWMA200 and isDownTrend == false
    isUpTrend := false
    isDownTrend := true
    
var int trendUp = 0
var int trendDown = 0

if isUpTrend
    if crossUpWMA13_48
        trendUp := 1
        trendDown := 0
    if crossUpWMA48_200
        trendUp := 2
        trendDown := 0
        
if isDownTrend
    if crossDownWMA13_48
        trendUp := 0
        trendDown := 1
    if crossDownWMA48_200
        trendUp := 0
        trendDown := 2
// trend strong end 


// clone start
periodMa = input.int(title='Delta Length', minval=1, defval=2)
iff_1 = o_c[1] < o_o ? math.max(o_h - o_c[1], o_c - o_l) : math.max(o_h - o_o, o_c - o_l)
iff_2 = o_c[1] > o_o ? o_h - o_l : math.max(o_o - o_c[1], o_h - o_l)
iff_3 = o_c[1] < o_o ? math.max(o_h - o_c[1], o_c - o_l) : o_h - o_o
iff_4 = o_c[1] > o_o ? o_h - o_l : math.max(o_o - o_c[1], o_h - o_l)
iff_5 = o_c[1] < o_o ? math.max(o_o - o_c[1], o_h - o_l) : o_h - o_l
iff_6 = o_c[1] > o_o ? math.max(o_h - o_o, o_c - o_l) : iff_5
iff_7 = o_h - o_c < o_c - o_l ? iff_4 : iff_6
iff_8 = o_h - o_c > o_c - o_l ? iff_3 : iff_7
iff_9 = o_c > o_o ? iff_2 : iff_8
bullPower = o_c < o_o ? iff_1 : iff_9
iff_10 = o_c[1] > o_o ? math.max(o_c[1] - o_o, o_h - o_l) : o_h - o_l
iff_11 = o_c[1] > o_o ? math.max(o_c[1] - o_l, o_h - o_c) : math.max(o_o - o_l, o_h - o_c)
iff_12 = o_c[1] > o_o ? math.max(o_c[1] - o_o, o_h - o_l) : o_h - o_l
iff_13 = o_c[1] > o_o ? math.max(o_c[1] - o_l, o_h - o_c) : o_o - o_l
iff_14 = o_c[1] < o_o ? math.max(o_o - o_l, o_h - o_c) : o_h - o_l
iff_15 = o_c[1] > o_o ? math.max(o_c[1] - o_o, o_h - o_l) : iff_14
iff_16 = o_h - o_c < o_c - o_l ? iff_13 : iff_15
iff_17 = o_h - o_c > o_c - o_l ? iff_12 : iff_16
iff_18 = o_c > o_o ? iff_11 : iff_17
bearPower = o_c < o_o ? iff_10 : iff_18

bullVolume = bullPower / (bullPower + bearPower) * volume
bearVolume = bearPower / (bullPower + bearPower) * volume

delta = bullVolume - bearVolume
cvd = ta.cum(delta)
cvdMa = ta.ema(cvd, periodMa)

deltagood = cvd > cvdMa
deltabad = cvd < cvdMa

// clone end 


// sideway start

low1d = request.security(symbol=syminfo.tickerid, timeframe="60", expression=o_l, lookahead=barmerge.lookahead_on)

avg = (o_c[10] + o_c[9] + o_c[8] + o_c[7] + o_c[6] +o_c[5] + o_c[4] + o_c[3] + o_c[2] + o_c[1])/10
keep_short = wma13 < wma48 and wma13 < avg and avg < wma48

start_long = wma13 > wma48 and wma13 > avg and avg > wma48 and (ta.crossover(wma13, wma48) and o_c > wma13 and o_c > wma48 or o_c > wma13 and ta.crossover(o_c, wma48) or o_c > wma48 and ta.crossover(o_c, wma13) or o_c[1] > wma13 and ta.crossover(wma13[1], wma200[1]))
keep_long = wma13 > wma48 and wma13 > avg and avg > wma48
sideway = math.abs(o_c[1]-avg)/avg < sideway_pct


// sideway end

bottomsupport = running_pl and o_c > running_pl and o_c > o_c[1] and rsi > rsi[1] + 8

bigdrop = rsi + 8 < rsi[1] and o_c > ema48 and running_ph and o_c < running_ph 

is_cross_res = ta.crossover(o_c, running_ph) and o_c > wma13 and wma13 > wma48

var bool is_long = false
var bool is_short = false

longCondition = (buy_trend and up10m and is_cross_res or up10m and buy_trend and (start_long or o_c*1.05 > wma13 and rsi > rsi[1] + 6 or rsi > rsi[1] + 8 and long or is_cross_up and bottomsupport and is_strong_buy or bottomsupport)) and barstate.isconfirmed


not_close_long = up10m and not down8m
is_lost = wma13[3] > wma13[2] and wma13[2] > wma13[1]
if is_lost
    longCondition := false

var int cnt_time_long = 0

if longCondition
    is_long := true

if is_long
    cnt_time_long := cnt_time_long + 1
    


shortCondition = down8m and (o_c*0.94 < wma13 and rsi + 8 < rsi[1] or rsi + 8 < rsi[1] and short or is_br or bigdrop and is_strong_sell) and barstate.isconfirmed

var int cnt_time_short = 0


if shortCondition
    is_short := true


if is_short
    cnt_time_short := cnt_time_short + 1

    //label.new(bar_index, low, text="*"+str.format("{0}", cnt_time_short), textcolor=color.yellow, style=label.style_triangleup, size=size.tiny)
    //shortCondition := false

////////////

var bool wma13_wma48_up = false
var bool wma13_wma48_down = false


if crossUpWMA13_48
    wma13_wma48_down := false
    wma13_wma48_up := true

if crossDownWMA13_48
    wma13_wma48_down := true
    wma13_wma48_up := false

if is_short and wma13_wma48_down or wma13 < wma48 and math.abs(wma13-wma48) < 0.008 or down8m
    longCondition := false

if is_long and wma13_wma48_up or wma13 > wma48 and math.abs(wma13-wma48) < 0.005 or wma13 < wma48 and wma13 < wma13[1]
    shortCondition := false

if up10m and down8m
    longCondition := false
    shortCondition := false

///////////

// close by macd start
fast_length = 7
slow_length = 20
signal_length = 7
// Calculating
fast_ma = ta.wma(src, fast_length)
slow_ma = ta.wma(src, slow_length)
macd = fast_ma - slow_ma
signal = ta.wma(macd, signal_length)
hist = macd - signal
is_cross_macd_short = ta.crossover(macd, signal) and macd < 0 and signal < 0

//plotshape(is_cross_macd_short ? low : na, title="Less", style=shape.diamond, location=location.absolute, color=color.yellow, size=size.tiny)


//label.new(bar_index, low1d*0.999, text="*"+str.format("{0}", math.abs(wma13-wma48)), textcolor=color.yellow, style=label.style_triangleup, size=size.tiny)
//plotshape(wma13 < wma48 and math.abs(wma13-wma48) < 0.005 ?  low1d: na, title="No Long", style=shape.xcross, location=location.absolute, color=color.gray, size=size.tiny)
//plotshape(wma13 > wma48 and math.abs(wma13-wma48) < 0.008 ?  low1d: na, title="No Short", style=shape.xcross, location=location.absolute, color=color.white, size=size.tiny)



plotshape(down8m ?  low1d*0.998: na, title="No Short", style=shape.xcross, location=location.absolute, color=color.yellow, size=size.tiny)
plotshape(up10m ?  low1d*0.995: na, title="No Short", style=shape.xcross, location=location.absolute, color=color.blue, size=size.tiny)



//plotshape(up10m and is_cross_res?  low: na, title="Go Strong", style=shape.xcross, location=location.absolute, color=color.orange, size=size.tiny)

// close by macd end


// exit long when has a short signal and otherwise
closelong = ((rsi > 70 ) and o_h[2] < o_h[1] and o_h[1] > o_h or down8m and (trendDown > 1 or profit_long or bigdrop and not is_cross_up or is_out_up ) or up10m[1] and not up10m) and barstate.isconfirmed


if not keep_long and is_long and o_h[2]*1.001 >= running_ph and (o_h[1] < running_ph and o_c[1] < running_ph or o_h[2] > o_h[1] and o_h[1] > o_h)
    closelong := true

next_short = false
if is_long and shortCondition
    closelong := true 
    shortCondition := false
    next_short := true

if next_short[1]
    shortCondition := true

//if minutes > 0 and cnt_time_long > minutes and ta.crossunder(close, wma13) and barstate.isconfirmed
//    closelong := true


if closelong
    is_long := false
    cnt_time_long := 0

closeshort = (down8m and up10m and wma13 < wma48 and math.abs(wma13-wma48) > 0.01  or not down8m and (hist < 0 and hist > hist[1] or trendUp > 1 or profit_short or bottomsupport and not is_cross_down) or down8m[1] and not down8m) and barstate.isconfirmed

next_long = false
if is_short and longCondition
    closeshort := true
    next_long := true
    longCondition := false

if next_long[1]
    longCondition := true

//if is_short and low[2]*0.9999 <= running_pl and low[1] > running_pl and close[1] > running_pl and low[3] > low[2] and low[2] < low[1]
//    closeshort := true
//if closeshort[1] and not longCondition and close > wma13 and close > wma48
//    longCondition := true

hr = hour(time_close, 'UTC-8')
mi = minute(time_close, 'UTC-8')

lock = input.bool(title = 'Lock Trade Pre Market and After Hour', defval = false)
lock_trade = lock and (hr >= 13 or hr < 6 or hr == 6 and mi <= 30)

if (longCondition and not lock_trade)
    strategy.entry("call", strategy.long) 

// change param rsi + 4
if (shortCondition  and not lock_trade)
    strategy.entry("put", strategy.short)

//if minutes > 0 and cnt_time_short > minutes and ta.crossover(close, wma13) and barstate.isconfirmed
//    closeshort := true
    
if closeshort
    is_short := false
    cnt_time_short := 0
   

if(strategy.position_size > 0)
    strategy.close(id="call", when=closelong and not not_close_long)
if(strategy.position_size < 0)
    strategy.close(id="put", when = closeshort)


if(strategy.position_size > 0)
    strategy.exit(id='call', limit=longTake,stop = longStop)
if(strategy.position_size < 0)
    strategy.exit(id='put', limit=shortTake,stop = shortStop)

Overview

Snag - No Repaint ES 1m Strategy Candle Bar calculates custom price aggregations, pivot levels, and averages across multiple higher timeframes including 3-minute, 5-minute, 8-minute, and 10-minute bars. Trades are managed with percentage-based stop loss, take profit targets, and a maximum holding time exit in minutes. Key settings adjust stop loss percentages, breakout factors, and session filters. Note that the script uses security calls with lookahead enabled, creating historical lookahead bias.

Details

Published by

dearvn on GitHub

Code credit

binancash, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Breakout, Moving averages, Support & resistance

Markets

Indices

Timeframes

M1-M5, M15-H1

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Topics

futures-markettradingviewtradovatetrading-futureses1best-indicator-tradingviewnq1trading-futurerus-stock-market

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Max minutes to exitint45minutes
Stop Loss %float0.05stopPer
Take Profit %int10takePer
Sideway %float0.08sideway_pct
Factor For Breakout Candlefloat3.1x
Delta Lengthint2periodMa
Lock Trade Pre Market and After Hourboolfalselock
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

106 stars

Breakout Trend Follower is a price-chart strategy that enters long when price breaks a recent swing high. It places the stop at the recent swing low and trails that stop upward as higher lows form, exiting when a higher low is breached. A pivot lookback sets h

Strategy v5 BreakoutTrend Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of Breakout Trend Follower
43 stars

This strategy trades SOL perpetual candles on the price chart. It tracks confirmed pivot highs and lows as support and resistance circles, then compares close with a smoothed filter and a three-period EMA to mark long and short conditions after the bar closes.

Strategy v5 Moving averagesSupport & resistance Repaints
Updated 2 years ago · None stated GitHub repository of SOL 1m Strategy Candle Bar
8 stars

This strategy identifies trend retracements and breakout entries using an adjustable moving average ribbon alongside higher-timeframe anchored moving averages, fractal pivots, and support and resistance level extensions. Bar colors can be customized using a 3-

Strategy v5 TrendMoving averages
Updated 4 years ago · None stated GitHub repository of Pullback Trading Tool ALT
7 stars

This overlay strategy tracks the high and low of a user-defined London session and plots the previous session levels as support and resistance. It flags a break beyond a level when price closes past an ATR buffer, then waits a set number of bars for a retest w

Strategy v5 Sessions & timeSupport & resistance
Updated 3 months ago · None stated GitHub repository of London SR Cleaner WR (TP 0.20)

This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr

Strategy v6 BreakoutTrend
Updated today · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout

Omar Edited WF

by Alorse
330 stars

Omar Edited WF is a trading strategy overlay built around Williams Fractals and multiple Exponential Moving Averages. It detects high and low fractal pivot points over configurable lookback periods alongside three adjustable EMA trendlines. Long entries are ma

Strategy v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of Omar Edited WF

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers