0% found this document useful (0 votes)
125 views104 pages

Pinescript Code Indicator

This Pine Script™ code implements a technical analysis indicator for TradingView, allowing users to visualize high timeframe (HTF) boxes and alerts based on market movements. It includes features for plotting bullish and bearish signals, as well as customizable colors and settings for user preferences. The script is designed to enhance trading strategies by identifying key price levels and trends in the market.

Uploaded by

Neo Jasta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views104 pages

Pinescript Code Indicator

This Pine Script™ code implements a technical analysis indicator for TradingView, allowing users to visualize high timeframe (HTF) boxes and alerts based on market movements. It includes features for plotting bullish and bearish signals, as well as customizable colors and settings for user preferences. The script is designed to enhance trading strategies by identifying key price levels and trends in the market.

Uploaded by

Neo Jasta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CODE 1

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/

// © cdikici71

// thanks to Rashid

//@version=5

indicator("cd_sweep&cisd_Cx",overlay=true,max_boxes_count = 500,max_lines_count = 100)

htf = input.timeframe(defval= "60", title = "HTF",group ="HTF",inline="htf")

showhtf = input.bool(defval = true,title = "Show HTF boxes",group="HTF",inline="htf")

indalert = input.bool(defval = true,title = "Use indicator alerts",group="HTF",inline="al",tooltip =


"When using the TradingView alert feature, it should be inactive.")

looksmt = input.bool(defval = true,title = "Show SMT",group="HTF",inline="smt")

show_candle= input.bool(defval = true,title = "Show HTF Candle",group="HTF",inline="htf1")

dx= input(defval= 0 ,title = " start from ahead",group="HTF",inline="htf1")

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

htfbias = input.timeframe(defval= "60", title = "HTF for bias",group ="BIAS")

plotbias= input.bool(defval = true,title='Plot Htf Bias',group ="BIAS" )

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

bull_color =input.color(defval = color.teal, title=" Bull Color " , inline="clr", group= "Colors")

bear_color =input.color(defval = color.red, title=" Bull Color " , inline="clr", group= "Colors")

htf_box_color = input.color(defval=color.navy,title= "Box Color",inline="clr1",group="Colors")

swept_color = input.color(defval= #ffeb3b32 ,title= "Swept Box


Color",inline="clr1",group="Colors")

/////

sym = syminfo.tickerid

tf = timeframe.period
var o0 = open

var h0 = high

var l0 = low

var h0bar = bar_index

var l0bar = bar_index

var h1bar = bar_index

var l1bar = bar_index

var h0t = time

var l0t = time

var t0 = time

var c0 = close

var h1 = high

var l1 = low

var t1 = time

var c1 = close

var o1 = open

var h2 = high

var l2 = low

var o2 = open

var c2 = close

var h3 = high

var l3 = low

var o3 = open

var c3 = close

var h_swept1 = false

var l_swept1 = false


if timeframe.change(htf)

t0 := time

o0 := open

h0 := high

l0 := low

if high >= h0

h0 := high

h0bar := bar_index

h0t := time

if low <= l0

l0 := low

l0bar := bar_index

l0t := time

c0:= close

if timeframe.change(htf)

o1 := o0[1]

h1 := h0[1]

l1 := l0[1]

t1 := t0[1]

c1 := close[1]

h2 := h1[1]

l2 := l1[1]

o2 := o1[1]

c2 := c1[1]

h3 := h2[1]

l3 := l2[1]
o3 := o2[1]

c3 := c2[1]

l1bar := l0bar[1]

h1bar := h0bar[1]

f_hswept(_sym,_tf)=>

if h0 > h1 and math.max(o0,c0) <= h1 //and o0 > c0

_h_swept = true

f_lswept(_sym,_tf)=>

if l0 < l1 and math.min(o0,c0) >= l1 //and o0 < c0

_l_swept = true

f_text(string _tf)=>

_text = str.tonumber(_tf) < 59 ? _tf + 'm' :

str.tonumber(_tf) > 59 ? str.tostring(math.floor(str.tonumber(_tf)/60)) + 'h' : _tf

f_tfcon(_tf)=>

timeframe.in_seconds(_tf) / 60 >= timeframe.in_seconds(timeframe.period)/60

Getcolor(_sym,res, data1, i1 , data2,i2) =>

[op,cl] = request.security(_sym, res, [data1[i1],data2[i2]], lookahead=barmerge.lookahead_on


,ignore_invalid_symbol = true)

clr = op > cl ? color.new(bear_color, 0) : color.new(bull_color,0)

clr
add_to_array(arr, value) =>

array.unshift(arr, value)

if array.size(arr) > 100

array.pop(arr)

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

h_swept = h0 > h1 and math.max(o0,c0) < h1 ? true : false

l_swept = l0 < l1 and math.min(o0,c0) > l1 ? true : false

if timeframe.change(htf)

h_swept1 := h_swept[1]

l_swept1 := l_swept[1]

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

var lasthighswept = 0

var lastlowswept = 0

if showhtf

xcolor = swept_color

if f_tfcon(htf) and time == t0 and timeframe.period != htf

boxhtf1=box.new(left = t1, top = h1 , right = t0, bottom = l1,xloc =


xloc.bar_time,border_width = 1,border_style = line.style_dotted,bgcolor =color.rgb(255, 255,
255, 100) , border_color =htf_box_color ,text = "",text_color= htf_box_color , text_size=size.tiny
,text_halign = text.align_right,text_valign = text.align_center )

if f_tfcon(htf) and timeframe.period != htf // live

boxhtf=box.new(left = t0, top = high > h0 ? high : h0 , right = time+1, bottom =low < l0 ? low
: l0,xloc = xloc.bar_time,border_width = 1,border_style = line.style_dotted,bgcolor
=color.rgb(255, 255, 255, 100) , border_color =htf_box_color ,text = "",text_color=
htf_box_color , text_size=size.tiny ,text_halign = text.align_right,text_valign = text.align_center )

box.delete(boxhtf[1])

if f_tfcon(htf) and timeframe.period != htf and h0 > h1 and close < h1 and o0 < h1

boxhtf4=box.new(left = t0, top = h0 , right = time, bottom = h1, xloc =


xloc.bar_time,border_width = 1,border_style = line.style_dotted,bgcolor =xcolor , border_color
=color.new(color.gray,70) )

lasthighswept := t0

if t0 == lasthighswept[1]

box.delete(boxhtf4[1])

if f_tfcon(htf) and timeframe.period != htf and l0 < l1 and close > l1 and o0 > l1

boxhtf5=box.new(left = t0, top = l1, right = time, bottom = l0, xloc =


xloc.bar_time,border_width = 1,border_style = line.style_dotted,bgcolor =xcolor , border_color
=color.new(color.gray,70) )

lastlowswept := t0

if t0 == lastlowswept[1]

box.delete(boxhtf5[1])

var bull_level = high

var bear_level = low

var bull_index = bar_index

var bear_index = bar_index

var bucisdg=array.new_line()

var becisdg=array.new_line()

var bull_alarm = false

var bear_alarm = false

var bull_cisd_ara = false


var bear_cisd_ara = false

var saybear = 0

var saybull = 0

var xcisd = false

var ycisd =false

var mm = bar_index

var nn = bar_index

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

if l_swept

bull_cisd_ara := true

if h_swept

bear_cisd_ara :=true

up = close > open

dw = close < open

eq = close == open

////////////////////////////////////// cisd

if low == l0 and low < l1

if (dw[0] or eq[0]) and (up[1] or eq[1]) and not (eq[0] and eq[1])

bull_level := open

bull_index := bar_index
add_to_array(bucisdg, line.new(x1= bull_index,y1= bull_level,x2= bull_index+4,y2=
bull_level,color=bull_color,width = 2,style=line.style_dotted))

else

for i = 2 to 10

if low[i] < low

break

if (up[i] or eq[i]) and dw[i-1]

bar = i - 1

bull_level := open[bar]

bull_index := bar_index - bar

bull_index := i > 1 and open[i-2] > bull_level ? bar_index - (i-2) : bull_index

bull_level := i > 1 and open[i-2] > bull_level ? open[i-2] : bull_level

if bull_level < open and not (close > open)

bull_level := open

bull_index := bar_index

if bull_level < open and (close > open)

bull_level := high

bull_index := bar_index

add_to_array(bucisdg, line.new(x1= bull_index,y1= bull_level,x2= bull_index+4,y2=


bull_level,color=bull_color,width = 2,style=line.style_dotted))

break

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

if high == h0 and high > h1//h_swept and

if (dw[1] or eq[1]) and up


bear_level := open

bear_index := bar_index

add_to_array( becisdg,line.new(x1= bear_index,y1= bear_level,x2= bear_index+4,y2=


bear_level,color=bear_color,width = 2,style=line.style_dotted))

if ((close[1] < open[1]or close[1]==open[1]) and close > open) == false

for i = 2 to 10

if high[i] > high

break

if (dw[i] or eq[i]) and up[i-1]

ybar = i - 1

bear_level := open[ybar]

bear_index := bar_index - ybar

bear_index := i > 1 and open[i-2] < bear_level ? bar_index - (i-2) : bear_index

bear_level := i > 1 and open[i-2] < bear_level ? open[i-2] : bear_level

if bear_level > open and not (close < open)

bear_level := open

bear_index := bar_index

if bear_level > open and (close < open)

bear_level := low

bear_index := bar_index

add_to_array( becisdg,line.new(x1= bear_index,y1= bear_level,x2= bear_index+4,y2=


bear_level,color=bear_color,width = 2,style=line.style_dotted))

break

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

if high >= h0[1]


saybear := 0

bear_cisd_ara := true

ycisd := false

if low <= l0[1]

saybull := 0

bull_cisd_ara := true

xcisd := false

/////////////////////////////cisd kesişim

m= l0 < l1 ? bar_index - l0bar : bar_index - l1bar

bullcisd = (close[1] > bull_level[1] and close[2] <= bull_level[1] and bar_index - bull_index[1] > 1
and l0 < l1 and m < 30 ) or

(close[1] > bull_level[1] and close[2] <= bull_level[1] and bar_index - bull_index[1] > 1 and l1 <
l0 and m < 30 and l_swept1 )

if bullcisd and xcisd[1] == false

xcisd := true

mm := bar_index

xbull = xcisd and saybull == 0 and bull_cisd_ara and ((l_swept[1] ) or (l_swept1 and l1 < l0 ))

if xbull

bucisd =box.new(left= bull_index[1], top= bull_level[1],right= mm-1, bottom=


bull_level[1],border_color = bull_color,border_width = 1,text="cisd+",text_color =
bull_color,text_size=size.tiny,text_halign = text.align_center,text_valign = text.align_bottom)

bull_alarm := true

if bull_alarm and saybull == 0


if not indalert

alert(sym + ',' + timeframe.period + ',🟢 Long Alarm"}', alert.freq_once_per_bar )

saybull := 1

bull_level := 1000000.0

bull_cisd_ara := false

xcisd := false

if array.size(bucisdg) > 0

dbox = array.get(bucisdg, 0)

line.delete(dbox)

array.remove(bucisdg,0)

if array.size(bucisdg) > 1

for i = array.size(bucisdg) - 1 to 1

dbox = array.get(bucisdg, i)

line.delete(dbox)

array.remove(bucisdg,i)

///////////

n= h0 > h1 ? bar_index - h0bar : bar_index - h1bar

bearcisd = (close[1] < bear_level[1] and close[2] >= bear_level[1] and bar_index - bear_index[1]
> 1 and h0 > h1 and n < 30 ) or

(close[1] < bear_level[1] and close[2] >= bear_level[1] and bar_index - bear_index[1] > 1 and h1
> h0 and n < 30 and h_swept1 )

if bearcisd and ycisd[1] == false

ycisd := true

nn := bar_index
xbear = ycisd and ((h_swept[1] ) or (h_swept1 and h1 > h0 ))and saybear == 0 and
bear_cisd_ara

if xbear

becisd =box.new(left= bear_index[1], top= bear_level[1],right= nn-1, bottom=


bear_level[1],border_color = bear_color,border_width =
1,text="cisd-",text_color=bear_color,text_size=size.tiny,text_halign =
text.align_center,text_valign = text.align_top)

bear_alarm := true

if bear_alarm and saybear == 0

if not indalert

alert(sym +',' + timeframe.period + ',🔴 Short Alarm"}', alert.freq_once_per_bar)

saybear := 1

bear_level := 0.0

bear_cisd_ara := false

ycisd := false

if array.size(becisdg) > 0

dbox = array.get(becisdg, 0)

line.delete(dbox)

array.remove(becisdg,0)

if array.size(becisdg)>1

for i = array.size(becisdg) - 1 to 1

dbox = array.get(becisdg, i)
line.delete(dbox)

array.remove(becisdg,i)

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

plotshape( bull_alarm, title = "Bullish


Cisd",style=shape.arrowup,location=location.belowbar,color=bull_color,size=size.small,text="",t
extcolor = color.green,offset = -1)

plotshape( bear_alarm, title = "Bearish


Cisd",style=shape.arrowdown,location=location.abovebar,color=bear_color,size=size.small,text=
"",textcolor = color.red,offset = -1)

sw1=line.new(na,na,na,na)

sw2=line.new(na,na,na,na)

xxo = o0 , xxc = c0 , xxh = h0 , xxl = l0

xxo1 = o1 , xxc1 = c1 , xxh1 = h1 , xxl1 = l1

xxo2 = o2 , xxc2 = c2 , xxh2 = h2 , xxl2 = l2

xxo3 = o3 , xxc3 = c3 , xxh3 = h3 , xxl3 = l3

if show_candle

if barstate.islast

line.delete(sw1[1])

line.delete(sw2[1])

bl0=box.new(left=bar_index+dx+18 ,top= xxc , right= bar_index+dx +20 , bottom = xxo,


bgcolor = Getcolor(sym,htf,open,0,close,0), border_color = Getcolor(sym,htf,open,0,close,0) ,
text = f_text(htf) , text_size = size.tiny ,text_valign = text.align_center , text_halign =
text.align_center,text_color = color.white )
wup=box.new(left=bar_index+dx+19 ,top= xxh , right= bar_index+dx +19 , bottom =
math.max(xxo,xxc) , border_color = Getcolor(sym,htf,open,0,close,0),border_width =1)

wdw=box.new(left=bar_index+dx+19 ,top= xxl , right= bar_index+dx +19 , bottom =


math.min(xxo,xxc) , border_color = Getcolor(sym,htf,open,0,close,0),border_width =1)

bl01=box.new(left=bar_index+dx+15 ,top= xxc1 , right= bar_index+dx +17 , bottom = xxo1,


bgcolor = Getcolor(sym,htf,open,1,close,1), border_color = Getcolor(sym,htf,open,1,close,1) ,
text = f_text(htf), text_size = size.tiny ,text_valign = text.align_center , text_halign =
text.align_center,text_color = color.white )

wup1=box.new(left=bar_index+dx+16 ,top= xxh1 , right= bar_index+dx +16 , bottom =


math.max(xxo1,xxc1) , border_color = Getcolor(sym,htf,open,1,close,1),border_width =1)

wdw1=box.new(left=bar_index+dx+16 ,top= xxl1 , right= bar_index+dx +16 , bottom =


math.min(xxo1,xxc1) , border_color = Getcolor(sym,htf,open,1,close,1),border_width =1)

bl02=box.new(left=bar_index+dx+12 ,top= xxc2 , right= bar_index+dx +14 , bottom = xxo2,


bgcolor = Getcolor(sym,htf,open,2,close,2), border_color = Getcolor(sym,htf,open,2,close,2) ,
text = f_text(htf) , text_size = size.tiny ,text_valign = text.align_center , text_halign =
text.align_center,text_color = color.white )

wup2=box.new(left=bar_index+dx+13 ,top= xxh2 , right= bar_index+dx +13 , bottom =


math.max(xxo2,xxc2) , border_color = Getcolor(sym,htf,open,2,close,2),border_width =1)

wdw2=box.new(left=bar_index+dx+13 ,top= xxl2 , right= bar_index+dx +13 , bottom =


math.min(xxo2,xxc2) , border_color = Getcolor(sym,htf,open,2,close,2),border_width =1)

bl03=box.new(left=bar_index+dx+9 ,top= xxc3 , right= bar_index+dx +11 , bottom = xxo3,


bgcolor = Getcolor(sym,htf,open,3,close,3), border_color = Getcolor(sym,htf,open,3,close,3) ,
text = f_text(htf) , text_size = size.tiny ,text_valign = text.align_center , text_halign =
text.align_center,text_color = color.white )

wup3=box.new(left=bar_index+dx+10 ,top= xxh3 , right= bar_index+dx +10 , bottom =


math.max(xxo3,xxc3) , border_color = Getcolor(sym,htf,open,3,close,3),border_width =1)

wdw3=box.new(left=bar_index+dx+10 ,top= xxl3 , right= bar_index+dx +10 , bottom =


math.min(xxo3,xxc3) , border_color = Getcolor(sym,htf,open,3,close,3),border_width =1)
box.delete(bl0[1])

box.delete(bl01[1])

box.delete(bl02[1])

box.delete(bl03[1])

box.delete(wup[1])

box.delete(wdw[1])

box.delete(wup1[1])

box.delete(wdw1[1])

box.delete(wup2[1])

box.delete(wdw2[1])

box.delete(wup3[1])

box.delete(wdw3[1])

if xxh > xxh1 and xxh1 > math.max(xxo,xxc) and h_swept

sw1 := line.new(x1 = bar_index+dx+16, y1 = xxh1 , x2= bar_index+dx +19,y2 =xxh1, color


= bear_color , style = line.style_solid,width = 2)

line.delete(sw1[1])

if xxl < xxl1 and xxl1 < math.min(xxo,xxc) and l_swept

sw2 := line.new(x1 = bar_index+dx+16, y1 = xxl1 , x2= bar_index+dx +19,y2 =xxl1, color =


bull_color, style = line.style_solid,width = 2)

line.delete(sw2[1])

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

show_cisd=input.bool(defval= true , title= "Show CISD table",group="Table")


//Turn Table On/Off

tableOn = input.bool(true, title="HTF Swept Table ", group="Table")

//Table Location & Size

i_font = input.string("small", "Text size", options = ["tiny", "small", "normal", "large",


"huge"], group = "Table")

i_pos = input.string(position.middle_right, "Table Position", inline = "1", options =


[position.middle_right, position.top_right,position.bottom_right,position.bottom_center],
group = "Table")

i_bgcolor = color.teal

i_textcolor= color.white

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

//pairs

s1=input.symbol(defval = "PEPPERSTONE:EURUSD", title = "1 : " , group = "Pairs",inline="s1")

s2=input.symbol(defval = "PEPPERSTONE:GBPUSD", title = "2 : " , group = "Pairs",inline="s2")

s3=input.symbol(defval = "PEPPERSTONE:NAS100", title = "3 : " , group = "Pairs",inline="s3")

s4=input.symbol(defval = "PEPPERSTONE:US500", title = "4 : " , group = "Pairs",inline="s4")

s5=input.symbol(defval = "PEPPERSTONE:XAUUSD", title = "5 : " , group = "Pairs",inline="s5")

s6=input.symbol(defval = "PEPPERSTONE:XAGUSD", title = "6 : " , group = "Pairs",inline="s6")

/// corele pairs

ss1=input.symbol(defval = "PEPPERSTONE:GBPUSD", title = "Cor: " , group = "Pairs",inline="s1")

ss2=input.symbol(defval = "PEPPERSTONE:EURUSD", title = "Cor: " , group = "Pairs",inline="s2")

ss3=input.symbol(defval = "PEPPERSTONE:US500", title = "Cor: " , group = "Pairs",inline="s3")

ss4=input.symbol(defval = "PEPPERSTONE:NAS100", title = "Cor: " , group = "Pairs",inline="s4")

ss5=input.symbol(defval = "PEPPERSTONE:XAGUSD", title = "Cor: " , group = "Pairs",inline="s5")


ss6=input.symbol(defval = "PEPPERSTONE:XAUUSD", title = "Cor: " , group = "Pairs",inline="s6")

s1_bull = request.security(s1,tf,xbull,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s1_bear = request.security(s1,tf,xbear,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s2_bull = request.security(s2,tf,xbull,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s2_bear = request.security(s2,tf,xbear,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s3_bull = request.security(s3,tf,xbull,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s3_bear = request.security(s3,tf,xbear,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s4_bull = request.security(s4,tf,xbull,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s4_bear = request.security(s4,tf,xbear,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s5_bull = request.security(s5,tf,xbull,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s5_bear = request.security(s5,tf,xbear,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s6_bull = request.security(s6,tf,xbull,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s6_bear = request.security(s6,tf,xbear,
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

//////

if s1_bull and indalert

alert( s1 + ',' + timeframe.period + ',🟢 Long Alarm"}', alert.freq_once_per_bar)


if s2_bull and indalert

alert( s2 + ',' + timeframe.period + ',🟢 Long Alarm"}', alert.freq_once_per_bar)

if s3_bull and indalert

alert( s3 + ',' + timeframe.period + ',🟢 Long Alarm"}', alert.freq_once_per_bar)

if s4_bull and indalert

alert( s4 + ',' + timeframe.period + ',🟢 Long Alarm"}', alert.freq_once_per_bar)

if s5_bull and indalert

alert( s5 + ',' + timeframe.period + ',🟢 Long Alarm"}', alert.freq_once_per_bar)

if s6_bull and indalert

alert( s6 + ',' + timeframe.period + ',🟢 Long Alarm"}', alert.freq_once_per_bar)

if s1_bear and indalert

alert(s1 + ',' + timeframe.period + ',🔴 Short Alarm"}', alert.freq_once_per_bar)

if s2_bear and indalert

alert(s2 + ',' + timeframe.period + ',🔴 Short Alarm"}', alert.freq_once_per_bar)

if s3_bear and indalert

alert(s3 + ',' + timeframe.period + ',🔴 Short Alarm"}', alert.freq_once_per_bar)

if s4_bear and indalert

alert(s4 + ',' + timeframe.period + ',🔴 Short Alarm"}', alert.freq_once_per_bar)

if s5_bear and indalert

alert(s5 + ',' + timeframe.period + ',🔴 Short Alarm"}', alert.freq_once_per_bar)

if s6_bear and indalert

alert(s6 + ',' + timeframe.period + ',🔴 Short Alarm"}', alert.freq_once_per_bar)

s1_h_swept = request.security(s1,tf,f_hswept(s1,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)
s2_h_swept = request.security(s2,tf,f_hswept(s2,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s3_h_swept = request.security(s3,tf,f_hswept(s3,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s4_h_swept = request.security(s4,tf,f_hswept(s4,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s5_h_swept = request.security(s5,tf,f_hswept(s5,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s6_h_swept = request.security(s6,tf,f_hswept(s5,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s1_l_swept = request.security(s1,tf,f_lswept(s1,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s2_l_swept = request.security(s2,tf,f_lswept(s2,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s3_l_swept = request.security(s3,tf,f_lswept(s3,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s4_l_swept = request.security(s4,tf,f_lswept(s4,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s5_l_swept = request.security(s5,tf,f_lswept(s5,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

s6_l_swept = request.security(s6,tf,f_lswept(s6,htf),
lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true)

// Compose a screener message

swept_label = ' ' + f_text(htf) + ' Swept \n ------------------------\n'

swept_label := s1_h_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s1)) +" "+


f_text(htf) +" 🔴 " + '\n' : swept_label

swept_label := s2_h_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s2)) +" "+


f_text(htf) +" 🔴 " + '\n' : swept_label
swept_label := s3_h_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s3)) +" "+
f_text(htf) +" 🔴 " + '\n' : swept_label

swept_label := s4_h_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s4)) +" "+


f_text(htf) +" 🔴 " + '\n' : swept_label

swept_label := s5_h_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s5)) +" "+


f_text(htf) +" 🔴 " + '\n' : swept_label

swept_label := s6_h_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s6)) +" "+


f_text(htf) +" 🔴 " + '\n' : swept_label

swept_label := s1_l_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s1)) +" "+ f_text(htf)


+" 🟢 " + '\n' : swept_label

swept_label := s2_l_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s2)) +" "+ f_text(htf)


+" 🟢 " + '\n' : swept_label

swept_label := s3_l_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s3)) +" "+ f_text(htf)


+" 🟢 " + '\n' : swept_label

swept_label := s4_l_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s4)) +" "+ f_text(htf)


+" 🟢 " + '\n' : swept_label

swept_label := s5_l_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s5)) +" "+ f_text(htf)


+" 🟢 " + '\n' : swept_label

swept_label := s6_l_swept ? swept_label + "⚠️"+str.tostring(syminfo.ticker(s6)) +" "+ f_text(htf)


+" 🟢 " + '\n' : swept_label

//Plot Label

dataTable = table.new(position = i_pos, columns=1, rows=3, bgcolor=#00000000)

if tableOn and barstate.islast

table.cell(table_id=dataTable, column=0, row=0, text=swept_label, height=0,


text_color=i_textcolor, text_halign=text.align_left, text_valign= text.align_center,
text_size=i_font, bgcolor=i_bgcolor)

///////////////////////////////////////////////////
f_tb2_text(bool _alarm) =>

_textt = _alarm ? "🔥" : "🕒"

var tablo2 = table.new(position = position.bottom_right,columns = 3,rows =


11,frame_color=i_textcolor,frame_width=2,border_color=i_textcolor,border_width=1)

if show_cisd

table.cell(tablo2,0,0,text="CISD" ,text_color=i_textcolor,bgcolor= i_bgcolor, text_size = i_font)

table.cell(tablo2,1,0,text="Bullish" ,text_color=i_textcolor,bgcolor= i_bgcolor, text_size =


i_font)

table.cell(tablo2,2,0,text="Bearish" ,text_color=i_textcolor,bgcolor= i_bgcolor, text_size =


i_font)

table.cell(tablo2,0,1,text= syminfo.ticker(s1) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,1,1,text= f_tb2_text(s1_bull) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,2,1,text= f_tb2_text(s1_bear) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,0,2,text= syminfo.ticker(s2) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,1,2,text= f_tb2_text(s2_bull) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,2,2,text= f_tb2_text(s2_bear) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,0,3,text= syminfo.ticker(s3) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,1,3,text= f_tb2_text(s3_bull) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)
table.cell(tablo2,2,3,text= f_tb2_text(s3_bear) ,text_color=i_textcolor,bgcolor= i_bgcolor,
text_size = i_font)

table.cell(tablo2,0,4,text= syminfo.ticker(s4) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,1,4,text= f_tb2_text(s4_bull) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,2,4,text= f_tb2_text(s4_bear) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,0,5,text= syminfo.ticker(s5) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,1,5,text= f_tb2_text(s5_bull) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,2,5,text= f_tb2_text(s5_bear) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,0,6,text= syminfo.ticker(s6) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,1,6,text= f_tb2_text(s6_bull) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

table.cell(tablo2,2,6,text= f_tb2_text(s6_bear) ,text_color=i_textcolor,bgcolor= i_bgcolor,


text_size = i_font)

//////////////////////////////////bias

var bo0 = open

var bh0 = high

var bl0 = low


var bt0 = time

var bc0 = close

var bh1 = high

var bl1 = low

var bt1 = time

var bc1 = close

var bo1 = open

var bh2 = high

var bl2 = low

var bo2 = open

var bc2 = close

var bias = 0

if timeframe.change(htfbias)

bt0 := time

bo0 := open

bh0 := high

bl0 := low

if high >= bh0

bh0 := high

if low <= bl0

bl0 := low

bc0:= close
if timeframe.change(htfbias)

bo1 := bo0[1]

bh1 := bh0[1]

bl1 := bl0[1]

bt1 := bt0[1]

bc1 := close[1]

bh2 := bh1[1]

bl2 := bl1[1]

bo2 := bo1[1]

bc2 := bc1[1]

if timeframe.change(htfbias)

bias:= 0

if bc1 > bh2

bias := 1

if bc1 < bl2

bias := -1

if bc1 < bh2 and bc1 > bl2 and bh1 > bh2 and bl1 > bl2

bias := -1

if bc1 > bl2 and bc1 < bh2 and bh1 < bh2 and bl1 < bl2

bias := 1

if bh1 <= bh2 and bl1 >= bl2

if bc2 > bo2

bias := 1
else

bias := -1

plotshape(plotbias, 'htf Bias', style = shape.square, size = size.tiny, location = location.bottom,


color = bias == 1 ? bull_color :bias == -1 ? bear_color :bias == 0 ? color.gray : na)

///////////SMT

var lb1=label.new(na,na)

var lb2=label.new(na,na)

csym = str.contains(sym,s1) ? ss1 : str.contains(sym,s2) ? ss2 : str.contains(sym,s3) ? ss3 :


str.contains(sym,s4) ? ss4 : str.contains(sym,s5) ? ss5 : str.contains(sym,s6) ? ss6 : sym

c_l = request.security(csym,htf,low < low[1] ,


lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true) ? true : false

c_h = request.security(csym,htf,high > high[1],


lookahead=barmerge.lookahead_on ,ignore_invalid_symbol = true) ? true : false

da = ta.atr(20)*1.25

tf_ok = timeframe.in_seconds(tf) < timeframe.in_seconds(htf)

if looksmt and tf_ok

if ( (l0 < l1 and c_l == false) or ( l0 >= l1 and c_l) )

lb1 := label.new(x= l0t , y= l0 - da ,xloc=xloc.bar_time,text= "SMT",color=color.teal,style =


label.style_label_up,textcolor=color.white,size =i_font )

label.delete(lb1[1])

else

label.delete(lb1[1])

if looksmt and tf_ok

if ( (h0 > h1 and c_h == false) or ( h0 <= h1 and c_h) )

lb2 :=label.new(x= h0t , y= h0 + da,xloc=xloc.bar_time,text= "SMT",color=color.teal,style =


label.style_label_down,textcolor=color.white,size =i_font)
label.delete(lb2[1])

else

label.delete(lb2[1])

bull_alarm := false

bear_alarm := false

------

CODE 2

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-


NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/

// © LuxAlgo

//@version=5

indicator('Change in State of Delivery (CISD) [LuxAlgo]', shorttitle='LuxAlgo - CISD',


max_labels_count=500, max_lines_count=500, overlay=true)

//---------------------------------------------------------------------------------------------------------------------}

// Settings

//---------------------------------------------------------------------------------------------------------------------{

space = ' '

Tracking_Method = input.string ('Classic', 'Detection Method'

, options =['Classic', 'Liquidity Sweep'] )

length = input.int( 10, 'Swing Length' , minval=1

, tooltip = 'Only applicable on the Liquidity Sweep Detection Method' )


Minimum_Sequence_Length = input.int( 0, 'Minimum CISD Duration' , minval=0
)

Maximum_Sequence_Length = input.int(100, 'Maximum Swing Validity' , minval=1,


maxval=1000

, tooltip = 'Maximum allowed swing level duration without a new detected


sweep' )

textSize = str.lower(input.string( 'Tiny', 'Label/Text Size' , group='Style', options =['Tiny',


'Small']))

cBull = input.color(#089981 , 'Bullish' , group='Style' )

cBear = input.color(#f23645 , 'Bearish' , group='Style' )

cSweepH = input.color(#787b8684, 'Sweeps' + space, group='Style', inline="S"


)

cSweepL = input.color(#787b8684, '' , group='Style', inline="S", tooltip='Sweep


High/Low')

//---------------------------------------------------------------------------------------------------------------------}

//LuxAlgo Defined Types

//---------------------------------------------------------------------------------------------------------------------{

type bin

line ln

bool active

chart.point cp1

chart.point cp2

bool broken = false

type swing

chart.point cp

line ln
line wick

bool active = false

//---------------------------------------------------------------------------------------------------------------------}

//Constants and general variables

//---------------------------------------------------------------------------------------------------------------------{

INV = color(na)

n = bar_index

//---------------------------------------------------------------------------------------------------------------------}

//Variables

//---------------------------------------------------------------------------------------------------------------------{

bull = close > open

bear = close < open

sweep = Tracking_Method == 'Liquidity Sweep'

var int trend =0

var array<bin> arrBull = array.new<bin>()

var array<bin> arrBear = array.new<bin>()

var array<swing>swingsH = array.new<swing>()

var array<swing>swingsL = array.new<swing>()

var chart.point cp_lastPh = chart.point.from_index(n , high)

var chart.point cp_lastPl = chart.point.from_index(n , low )

var chart.point trackPriceBull = chart.point.from_index(na, na )

var chart.point trackPriceBear = chart.point.from_index(na, na )


var bin oBull = bin.new(

line.new(n, open, n, open, color=color.green)

, true

, chart.point.from_index(n, high)

, chart.point.from_index(n, high)

var bin oBear = bin.new(

line.new(n, open, n, open, color=color.red )

, true

, chart.point.from_index(n, low )

, chart.point.from_index(n, low )

//---------------------------------------------------------------------------------------------------------------------}

//Execution

//---------------------------------------------------------------------------------------------------------------------{

ph = ta.pivothigh(length, 1)

pl = ta.pivotlow (length, 1)

if not na(ph)

swingsH.push(swing.new(chart.point.from_index(n-1, ph)))

cp_lastPh := chart.point.from_index(n-1, ph)

if not na(pl)

swingsL.push(swing.new(chart.point.from_index(n-1, pl)))

cp_lastPl := chart.point.from_index(n-1, pl)


if bull and bear[1]

trackPriceBull := chart.point.from_index(n, open)

if bear and bull[1]

trackPriceBear := chart.point.from_index(n, open)

//Reset when last Swing is broken

if close > cp_lastPh.price

cp_lastPh := chart.point.from_index(na, na)

if close < cp_lastPl.price

cp_lastPl := chart.point.from_index(na, na)

//Not Sweep

//#region

if not sweep

//Bearish

if barstate.isconfirmed and bull and bear[1]

if oBull.active

if not oBull.broken

oBull.ln.delete()

oBull.active := true

oBull.ln := line.new(trackPriceBull.index, trackPriceBull.price, n, trackPriceBull.price,


color=color.new(cBull, 40))
oBull.cp1 := chart.point.from_index(cp_lastPh.index, cp_lastPh.price)

oBull.cp2 := chart.point.from_index(n, cp_lastPh.price)

oBull.broken := false

//Bullish

if barstate.isconfirmed and bear and bull[1]

if oBear.active

if not oBear.broken

oBear.ln.delete()

oBear.active := true

oBear.ln := line.new(trackPriceBear.index, trackPriceBear.price, n, trackPriceBear.price,


color=color.new(cBear, 40))

oBear.cp1 := chart.point.from_index(cp_lastPl.index, cp_lastPl.price)

oBear.cp2 := chart.point.from_index(n, cp_lastPl.price)

oBear.broken := false

//Bearish CISD

if oBull.active

if n - oBull.ln.get_x1() <= Maximum_Sequence_Length

oBull.ln.set_x2(n)

if close < oBull.ln.get_y2()

if n - oBull.ln.get_x1() >= Minimum_Sequence_Length

oBull.ln.set_color(cBear)

if trend ==-1

oBull.ln.set_style(line.style_dashed)
oBull.active := false

oBull.broken := true

trend :=-1

x1 = oBull.ln.get_x1()

x = math.ceil(math.avg(x1, n))

label.new(x, oBull.ln.get_y2()

, style= label.style_label_up

, textcolor=cBear, text='CISD'

, size=textSize

, color=INV

else

oBull.active := false

oBull.ln.delete()

else

oBull.active := false

oBull.ln.delete()

//Bullish CISD

if oBear.active

if n - oBear.ln.get_x1() <= Maximum_Sequence_Length

oBear.ln.set_x2(n)

if close > oBear.ln.get_y2()

if n - oBear.ln.get_x1() >= Minimum_Sequence_Length

oBear.ln.set_color(cBull)
if trend == 1

oBear.ln.set_style(line.style_dashed)

oBear.active := false

oBear.broken := true

trend := 1

x1 = oBear.ln.get_x1()

x = math.ceil(math.avg(x1, n))

label.new(x, oBear.ln.get_y2()

, style= label.style_label_down

, textcolor=cBull, text='CISD'

, color=INV, size=textSize

else

oBear.active := false

oBear.ln.delete()

else

oBear.active := false

oBear.ln.delete()

//#endregion

//Sweep

//#region

else

if swingsH.size() > 0

max_bars_back(close, 1000)

for i = swingsH.size() -1 to 0
get = swingsH.get(i)

x = get.cp.index

y = get.cp.price

//Too far back

if n - x > Maximum_Sequence_Length

swingsH.remove(i)

else

//if line swing available

if not na(get.ln)

//if broken

if close > get.ln.get_y2()

swingsH.remove(i)

else

if close > y

swingsH.remove(i)

else

//Show swing/sweeps - also in 'regular mode'

//First time sweep of line

if not get.active

if high > get.cp.price and close < get.cp.price

get.ln := line.new(x, get.cp.price, n, get.cp.price, color=cSweepH)

get.wick := line.new(n, get.cp.price, n, high, color=cSweepH, width=3)

get.active := true

//check if not broken already

good = true
for j = 0 to n - trackPriceBull.index

if close[j] < trackPriceBull.price

good := false

break

if good

arrBull.push(bin.new(

line.new(trackPriceBull.index, trackPriceBull.price, n, trackPriceBull.price,


color=color.new(cBull, 40))

, true

, chart.point.from_index(cp_lastPh.index, cp_lastPh.price)

, chart.point.from_index(n, cp_lastPh.price)

if swingsL.size() > 0

max_bars_back(close, 1000)

for i = swingsL.size() -1 to 0

get = swingsL.get(i)

x = get.cp.index

y = get.cp.price

//Too far back

if n - x > Maximum_Sequence_Length

swingsL.remove(i)

else

//if line swing available

if not na(get.ln)

//if broken
if close < get.ln.get_y2()

swingsL.remove(i)

else

if close < y

swingsL.remove(i)

else

//Show swing/sweeps - also in 'regular mode'

if not get.active

if low < get.cp.price and close > get.cp.price

get.ln := line.new(x, get.cp.price, n, get.cp.price, color=cSweepL)

get.wick := line.new(n, get.cp.price, n, low , color=cSweepL, width=3)

get.active := true

//check if not broken already

good = true

for j = 0 to n - trackPriceBear.index

if close[j] > trackPriceBear.price

good := false

break

if good

arrBear.push(bin.new(

line.new(trackPriceBear.index, trackPriceBear.price, n,
trackPriceBear.price, color=color.new(cBear, 40))

, true

, chart.point.from_index(cp_lastPl.index, cp_lastPl.price)

, chart.point.from_index(n, cp_lastPl.price)
)

if arrBull.size() > 0

for i = arrBull.size() -1 to 0

get = arrBull.get(i)

get.ln.set_x2(n)

x1 = get.ln.get_x1()

if n - x1 > Maximum_Sequence_Length

get.ln.delete()

arrBull.remove(i)

else

if close < get.ln.get_y2()

if n - x1 >= Minimum_Sequence_Length

get.ln.set_color(cBear)

if trend ==-1

get.ln.set_style(line.style_dashed)

trend := -1

x = math.ceil(math.avg(x1, n))

label.new(x, get.ln.get_y2()

, style= label.style_label_up

, textcolor=cBear, text='CISD'

, size=textSize

, color=INV

label.new(n, high

, style=label.style_label_down
, textcolor=cBear, text='▼'

, size=textSize

, color=INV

else

get.ln.delete()

arrBull.remove(i)

if arrBear.size() > 0

for i = arrBear.size() -1 to 0

get = arrBear.get(i)

get.ln.set_x2(n)

x1 = get.ln.get_x1()

if n - x1 > Maximum_Sequence_Length

get.ln.delete()

arrBear.remove(i)

else

if close > get.ln.get_y2()

if n - x1 >= Minimum_Sequence_Length

get.ln.set_color(cBull)

if trend == 1

get.ln.set_style(line.style_dashed)

trend := 1

x = math.ceil(math.avg(x1, n))

label.new(x, get.ln.get_y2()
, style= label.style_label_down

, textcolor=cBull, text='CISD'

, size=textSize

, color=INV

label.new(n, low

, style=label.style_label_up

, textcolor=cBull, text='▲'

, size=textSize

, color=INV

else

get.ln.delete()

arrBear.remove(i)

//#endregion

//---------------------------------------------------------------------------------------------------------------------}

CODE 3

// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/

// © tradeforopp

//@version=5

indicator("ICT Killzones & Pivots [TFO]", "ICT Killzones & Pivots [TFO]", true, max_labels_count =
500, max_lines_count = 500, max_boxes_count = 500)
// ---------------------------------------- Constant Functions --------------------------------------------------

get_line_type(_style) =>

result = switch _style

'Solid' => line.style_solid

'Dotted' => line.style_dotted

'Dashed' => line.style_dashed

result

get_size(x) =>

result = switch x

'Auto' => size.auto

'Tiny' => size.tiny

'Small' => size.small

'Normal' => size.normal

'Large' => size.large

'Huge' => size.huge

get_table_pos(pos) =>

result = switch pos

"Bottom Center" => position.bottom_center

"Bottom Left" => position.bottom_left

"Bottom Right" => position.bottom_right

"Middle Center" => position.middle_center

"Middle Left" => position.middle_left


"Middle Right" => position.middle_right

"Top Center" => position.top_center

"Top Left" => position.top_left

"Top Right" => position.top_right

// ---------------------------------------- Constant Functions --------------------------------------------------

// ---------------------------------------- Inputs --------------------------------------------------

var g_SETTINGS = "Settings"

max_days = input.int(3, "Session Drawing Limit", 1, tooltip = "Only this many drawings will
be kept on the chart, for each selected drawing type (killzone boxes, pivot lines, open lines,
etc.)", group = g_SETTINGS)

tf_limit = input.timeframe("30", "Timeframe Limit", tooltip = "Drawings will not appear on


timeframes greater than or equal to this", group = g_SETTINGS)

gmt_tz = input.string('America/New_York', "Timezone", options =


['America/New_York','GMT-12','GMT-11','GMT-10','GMT-9','GMT-8','GMT-7','GMT-6','GMT-
5','GMT-4','GMT-3','GMT-2','GMT-
1','GMT+0','GMT+1','GMT+2','GMT+3','GMT+4','GMT+5','GMT+6','GMT+7','GMT+8','GMT+9','G
MT+10','GMT+11','GMT+12','GMT+13','GMT+14'], tooltip = "Note GMT is not adjusted to reflect
Daylight Saving Time changes", group = g_SETTINGS)

lbl_size = get_size(input.string('Normal', "Label Size", options = ['Auto', 'Tiny', 'Small',


'Normal', 'Large', 'Huge'], tooltip = "The size of all labels", group = g_SETTINGS))

txt_color = input.color(color.black, "Text Color", tooltip = "The color of all label and table
text", group = g_SETTINGS)

use_cutoff = input.bool(false, "Drawing Cutoff Time", inline = "CO", tooltip = "When


enabled, all pivots and open price lines will stop extending at this time", group = g_SETTINGS)

cutoff = input.session("1800-1801", "", inline = "CO", group = g_SETTINGS)

var g_KZ = "Killzones"


show_kz = input.bool(true, "Show Killzone Boxes", inline = "KZ", group = g_KZ)

show_kz_text = input.bool(true, "Display Text", inline = "KZ", group = g_KZ)

use_asia = input.bool(true, "", inline = "ASIA", group = g_KZ)

as_txt = input.string("Asia", "", inline = "ASIA", group = g_KZ)

asia = input.session("2000-0000", "", inline = "ASIA", group = g_KZ)

as_color = input.color(color.blue, "", inline = "ASIA", group = g_KZ)

use_london = input.bool(true, "", inline = "LONDON", group = g_KZ)

lo_txt = input.string("London", "", inline = "LONDON", group = g_KZ)

london = input.session("0200-0500", "", inline = "LONDON", group = g_KZ)

lo_color = input.color(color.red, "", inline = "LONDON", group = g_KZ)

use_nyam = input.bool(true, "", inline = "NYAM", group = g_KZ)

na_txt = input.string("NY AM", "", inline = "NYAM", group = g_KZ)

nyam = input.session("0930-1100", "", inline = "NYAM", group = g_KZ)

na_color = input.color(#089981, "", inline = "NYAM", group = g_KZ)

use_nylu = input.bool(true, "", inline = "NYLU", group = g_KZ)

nl_txt = input.string("NY Lunch", "", inline = "NYLU", group = g_KZ)

nylu = input.session("1200-1300", "", inline = "NYLU", group = g_KZ)

nl_color = input.color(color.yellow, "", inline = "NYLU", group = g_KZ)

use_nypm = input.bool(true, "", inline = "NYPM", group = g_KZ)

np_txt = input.string("NY PM", "", inline = "NYPM", group = g_KZ)

nypm = input.session("1330-1600", "", inline = "NYPM", group = g_KZ)


np_color = input.color(color.purple, "", inline = "NYPM", group = g_KZ)

box_transparency = input.int(70, "Box Transparency", 0, 100, group = g_KZ)

text_transparency = input.int(50, "Text Transparency", 0, 100, group = g_KZ)

var g_LABELS = "Killzone Pivots"

show_pivots = input.bool(true, "Show Pivots", inline = "PV", group = g_LABELS)

use_alerts = input.bool(true, "Alert Broken Pivots", inline = "PV", tooltip = "The desired
killzones must be enabled at the time that an alert is created, along with the show pivots
option, in order for alerts to work", group = g_LABELS)

show_midpoints = input.bool(false, "Show Pivot Midpoints", inline = "mp", group =


g_LABELS)

stop_midpoints = input.bool(true, "Stop Once Mitigated", inline = "mp", group = g_LABELS)

show_labels = input.bool(true, "Show Pivot Labels", inline = "LB", tooltip = "Show labels
denoting each killzone's high and low. Optionally choose to show the price of each level. Right
side will show labels on the right-hand side of the chart until they are reached", group =
g_LABELS)

label_price = input.bool(false, "Display Price", inline = "LB", group = g_LABELS)

label_right = input.bool(false, "Right Side", inline = "LB", group = g_LABELS)

ext_pivots = input.string("Until Mitigated", "Extend Pivots...", options = ['Until Mitigated',


'Past Mitigation'], group = g_LABELS)

ext_which = input.string("Most Recent", "...From Which Sessions", options = ['Most


Recent', 'All'], group = g_LABELS)

ash_str = input.string("AS.H", "Killzone 1 Labels", inline = "L_AS", group = g_LABELS)

asl_str = input.string("AS.L", "", inline = "L_AS", group = g_LABELS)

loh_str = input.string("LO.H", "Killzone 2 Labels", inline = "L_LO", group = g_LABELS)


lol_str = input.string("LO.L", "", inline = "L_LO", group = g_LABELS)

nah_str = input.string("NYAM.H", "Killzone 3 Labels", inline = "L_NA", group = g_LABELS)

nal_str = input.string("NYAM.L", "", inline = "L_NA", group = g_LABELS)

nlh_str = input.string("NYL.H", "Killzone 4 Labels", inline = "L_NL", group = g_LABELS)

nll_str = input.string("NYL.L", "", inline = "L_NL", group = g_LABELS)

nph_str = input.string("NYPM.H", "Killzone 5 Labels", inline = "L_NP", group = g_LABELS)

npl_str = input.string("NYPM.L", "", inline = "L_NP", group = g_LABELS)

kzp_style = get_line_type(input.string(defval = 'Solid', title = "Pivot Style", options =


['Solid', 'Dotted', 'Dashed'], inline = "KZP", group = g_LABELS))

kzp_width = input.int(1, "", inline = "KZP", group = g_LABELS)

kzm_style = get_line_type(input.string(defval = 'Dotted', title = "Midpoint Style", options =


['Solid', 'Dotted', 'Dashed'], inline = "KZM", group = g_LABELS))

kzm_width = input.int(1, "", inline = "KZM", group = g_LABELS)

var g_RNG = "Killzone Range"

show_range = input.bool(false, "Show Killzone Range", tooltip = "Show the most recent
ranges of each selected killzone, from high to low", group = g_RNG)

show_range_avg = input.bool(true, "Show Average", tooltip = "Show the average range of


each selected killzone", group = g_RNG)

range_avg = input.int(5, "Average Length", 0, tooltip = "This many previous sessions will be
used to calculate the average. If there isn't enough data on the current chart, it will use as many
sessions as possible", group = g_RNG)
range_pos = get_table_pos(input.string('Top Right', "Table Position", options = ['Bottom
Center', 'Bottom Left', 'Bottom Right', 'Middle Center', 'Middle Left', 'Middle Right', 'Top Center',
'Top Left', 'Top Right'], group = g_RNG))

range_size = get_size(input.string('Normal', "Table Size", options = ['Auto', 'Tiny', 'Small',


'Normal', 'Large', 'Huge'], group = g_RNG))

var g_DWM = "Day - Week - Month"

sep_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the


selected lines as possible. Otherwise, the session drawing limit will be used", group = g_DWM)

alert_HL = input.bool(false, "Alert High/Low Break", tooltip = "Alert when any selected
highs and lows are traded through. The desired timeframe's high/low option must be enabled at
the time that an alert is created", group = g_DWM)

show_d_open = input.bool(false, "D Open", inline = "DO", group = g_DWM)

dhl = input.bool(false, "High/Low", inline = "DO", tooltip = "", group = g_DWM)

ds = input.bool(false, "Separators", inline = "DO", tooltip = "Mark where a new day


begins", group = g_DWM)

d_color = input.color(color.blue, "", inline = "DO", group = g_DWM)

show_w_open = input.bool(false, "W Open", inline = "WO", group = g_DWM)

whl = input.bool(false, "High/Low", inline = "WO", tooltip = "", group = g_DWM)

ws = input.bool(false, "Separators", inline = "WO", tooltip = "Mark where a new week


begins", group = g_DWM)

w_color = input.color(#089981, "", inline = "WO", group = g_DWM)

show_m_open = input.bool(false, "M Open", inline = "MO", group = g_DWM)

mhl = input.bool(false, "High/Low", inline = "MO", tooltip = "", group = g_DWM)


ms = input.bool(false, "Separators", inline = "MO", tooltip = "Mark where a new
month begins", group = g_DWM)

m_color = input.color(color.red, "", inline = "MO", group = g_DWM)

htf_style = get_line_type(input.string(defval = 'Solid', title = "Style", options = ['Solid',


'Dotted', 'Dashed'], inline = "D0", group = g_DWM))

htf_width = input.int(1, "", inline = "D0", group = g_DWM)

dow_labels = input.bool(true, "Day of Week Labels", inline = "DOW", group = g_DWM)

dow_yloc = input.string('Bottom', "", options = ['Top', 'Bottom'], inline = "DOW", group =


g_DWM)

dow_xloc = input.string('Midnight', "", options = ['Midnight', 'Midday'], inline = "DOW",


group = g_DWM)

dow_hide_wknd = input.bool(true, "Hide Weekend Labels", group = g_DWM)

var g_OPEN = "Opening Prices"

open_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the


selected lines as possible. Otherwise, the session drawing limit will be used", group = g_OPEN)

use_h1 = input.bool(false, "", inline = "H1", group = g_OPEN)

h1_text = input.string("True Day Open", "", inline = "H1", group = g_OPEN)

h1 = input.session("0000-0001", "", inline = "H1", group = g_OPEN)

h1_color = input.color(color.black, "", inline = "H1", group = g_OPEN)

use_h2 = input.bool(false, "", inline = "H2", group = g_OPEN)

h2_text = input.string("06:00", "", inline = "H2", group = g_OPEN)

h2 = input.session("0600-0601", "", inline = "H2", group = g_OPEN)


h2_color = input.color(color.black, "", inline = "H2", group = g_OPEN)

use_h3 = input.bool(false, "", inline = "H3", group = g_OPEN)

h3_text = input.string("10:00", "", inline = "H3", group = g_OPEN)

h3 = input.session("1000-1001", "", inline = "H3", group = g_OPEN)

h3_color = input.color(color.black, "", inline = "H3", group = g_OPEN)

use_h4 = input.bool(false, "", inline = "H4", group = g_OPEN)

h4_text = input.string("14:00", "", inline = "H4", group = g_OPEN)

h4 = input.session("1400-1401", "", inline = "H4", group = g_OPEN)

h4_color = input.color(color.black, "", inline = "H4", group = g_OPEN)

use_h5 = input.bool(false, "", inline = "H5", group = g_OPEN)

h5_text = input.string("00:00", "", inline = "H5", group = g_OPEN)

h5 = input.session("0000-0001", "", inline = "H5", group = g_OPEN)

h5_color = input.color(color.black, "", inline = "H5", group = g_OPEN)

use_h6 = input.bool(false, "", inline = "H6", group = g_OPEN)

h6_text = input.string("00:00", "", inline = "H6", group = g_OPEN)

h6 = input.session("0000-0001", "", inline = "H6", group = g_OPEN)

h6_color = input.color(color.black, "", inline = "H6", group = g_OPEN)

use_h7 = input.bool(false, "", inline = "H7", group = g_OPEN)

h7_text = input.string("00:00", "", inline = "H7", group = g_OPEN)

h7 = input.session("0000-0001", "", inline = "H7", group = g_OPEN)

h7_color = input.color(color.black, "", inline = "H7", group = g_OPEN)


use_h8 = input.bool(false, "", inline = "H8", group = g_OPEN)

h8_text = input.string("00:00", "", inline = "H8", group = g_OPEN)

h8 = input.session("0000-0001", "", inline = "H8", group = g_OPEN)

h8_color = input.color(color.black, "", inline = "H8", group = g_OPEN)

hz_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = ['Solid',


'Dotted', 'Dashed'], inline = "H0", group = g_OPEN))

hz_width = input.int(1, "", inline = "H0", group = g_OPEN)

var g_VERTICAL = "Timestamps"

v_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the


selected lines as possible. Otherwise, the session drawing limit will be used", group =
g_VERTICAL)

use_v1 = input.bool(false, "", inline = "V1", group = g_VERTICAL)

v1 = input.session("0000-0001", "", inline = "V1", group = g_VERTICAL)

v1_color = input.color(color.black, "", inline = "V1", group = g_VERTICAL)

use_v2 = input.bool(false, "", inline = "V2", group = g_VERTICAL)

v2 = input.session("0800-0801", "", inline = "V2", group = g_VERTICAL)

v2_color = input.color(color.black, "", inline = "V2", group = g_VERTICAL)

use_v3 = input.bool(false, "", inline = "V3", group = g_VERTICAL)

v3 = input.session("1000-1001", "", inline = "V3", group = g_VERTICAL)

v3_color = input.color(color.black, "", inline = "V3", group = g_VERTICAL)


use_v4 = input.bool(false, "", inline = "V4", group = g_VERTICAL)

v4 = input.session("1200-1201", "", inline = "V4", group = g_VERTICAL)

v4_color = input.color(color.black, "", inline = "V4", group = g_VERTICAL)

vl_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = ['Solid',


'Dotted', 'Dashed'], inline = "V0", group = g_VERTICAL))

vl_width = input.int(1, "", inline = "V0", group = g_VERTICAL)

// ---------------------------------------- Inputs --------------------------------------------------

// ---------------------------------------- Variables & Constants --------------------------------------------------

type kz

string _title

box[] _box

line[] _hi_line

line[] _md_line

line[] _lo_line

label[] _hi_label

label[] _lo_label

bool[] _hi_valid

bool[] _md_valid
bool[] _lo_valid

float[] _range_store

float _range_current

type hz

line[] LN

label[] LB

bool[] CO

type dwm_hl

line[] hi_line

line[] lo_line

label[] hi_label

label[] lo_label

bool hit_high = false

bool hit_low = false

type dwm_info

string tf

float o = na

float h = na

float l = na

float ph = na

float pl = na
var as_kz = kz.new(as_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(),
array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(),
array.new_float())

var lo_kz = kz.new(lo_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(),


array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(),
array.new_float())

var na_kz = kz.new(na_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(),


array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(),
array.new_float())

var nl_kz = kz.new(nl_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(),


array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(),
array.new_float())

var np_kz = kz.new(np_txt, array.new_box(), array.new_line(), array.new_line(),


array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(),
array.new_bool(), array.new_float())

var hz_1 = hz.new(array.new_line(), array.new_label(), array.new_bool())

var hz_2 = hz.new(array.new_line(), array.new_label(), array.new_bool())

var hz_3 = hz.new(array.new_line(), array.new_label(), array.new_bool())

var hz_4 = hz.new(array.new_line(), array.new_label(), array.new_bool())

var hz_5 = hz.new(array.new_line(), array.new_label(), array.new_bool())

var hz_6 = hz.new(array.new_line(), array.new_label(), array.new_bool())

var hz_7 = hz.new(array.new_line(), array.new_label(), array.new_bool())

var hz_8 = hz.new(array.new_line(), array.new_label(), array.new_bool())

var d_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())

var w_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())

var m_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(),


array.new_label())
var d_info = dwm_info.new("D")

var w_info = dwm_info.new("W")

var m_info = dwm_info.new("M")

t_as = not na(time("", asia, gmt_tz))

t_lo = not na(time("", london, gmt_tz))

t_na = not na(time("", nyam, gmt_tz))

t_nl = not na(time("", nylu, gmt_tz))

t_np = not na(time("", nypm, gmt_tz))

t_co = not na(time("", cutoff, gmt_tz))

t_h1 = not na(time("", h1, gmt_tz))

t_h2 = not na(time("", h2, gmt_tz))

t_h3 = not na(time("", h3, gmt_tz))

t_h4 = not na(time("", h4, gmt_tz))

t_h5 = not na(time("", h5, gmt_tz))

t_h6 = not na(time("", h6, gmt_tz))

t_h7 = not na(time("", h7, gmt_tz))

t_h8 = not na(time("", h8, gmt_tz))

t_v1 = not na(time("", v1, gmt_tz))

t_v2 = not na(time("", v2, gmt_tz))

t_v3 = not na(time("", v3, gmt_tz))

t_v4 = not na(time("", v4, gmt_tz))

var d_sep_line = array.new_line()


var w_sep_line = array.new_line()

var m_sep_line = array.new_line()

var d_line = array.new_line()

var w_line = array.new_line()

var m_line = array.new_line()

var d_label = array.new_label()

var w_label = array.new_label()

var m_label = array.new_label()

var v1_line = array.new_line()

var v2_line = array.new_line()

var v3_line = array.new_line()

var v4_line = array.new_line()

var transparent = #ffffff00

var ext_current = ext_which == 'Most Recent'

var ext_past = ext_pivots == 'Past Mitigation'

update_dwm_info(dwm_info n) =>

if timeframe.change(n.tf)

n.ph := n.h

n.pl := n.l

n.o := open

n.h := high
n.l := low

else

n.h := math.max(high, n.h)

n.l := math.min(low, n.l)

if dhl or show_d_open

update_dwm_info(d_info)

if whl or show_w_open

update_dwm_info(w_info)

if mhl or show_m_open

update_dwm_info(m_info)

// ---------------------------------------- Variables & Constants --------------------------------------------------

// ---------------------------------------- Functions --------------------------------------------------

get_box_color(color c) =>

result = color.new(c, box_transparency)

get_text_color(color c) =>

result = color.new(c, text_transparency)

// ---------------------------------------- Functions --------------------------------------------------

// ---------------------------------------- Core Logic --------------------------------------------------

dwm_sep(string tf, bool use, line[] arr, color col) =>

if use
if timeframe.change(tf)

arr.unshift(line.new(bar_index, high*1.0001, bar_index, low, style = htf_style, width =


htf_width, extend = extend.both, color = col))

if not sep_unlimited and arr.size() > max_days

arr.pop().delete()

dwm_open(string tf, bool use, line[] lns, label[] lbls, dwm_info n, color col) =>

if use

if lns.size() > 0

lns.get(0).set_x2(time)

lbls.get(0).set_x(time)

if timeframe.change(tf)

lns.unshift(line.new(time, n.o, time, n.o, xloc = xloc.bar_time, style = htf_style, width =


htf_width, color = col))

lbls.unshift(label.new(time, n.o, tf + " OPEN", xloc = xloc.bar_time, style =


label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))

if not sep_unlimited and lns.size() > max_days

lns.pop().delete()

lbls.pop().delete()

dwm_hl(string tf, bool use, dwm_hl hl, dwm_info n, color col) =>

if use

if hl.hi_line.size() > 0

hl.hi_line.get(0).set_x2(time)

hl.lo_line.get(0).set_x2(time)
hl.hi_label.get(0).set_x(time)

hl.lo_label.get(0).set_x(time)

if timeframe.change(tf)

hl.hi_line.unshift(line.new(time, n.ph, time, n.ph, xloc = xloc.bar_time, style = htf_style,


width = htf_width, color = col))

hl.lo_line.unshift(line.new(time, n.pl, time, n.pl, xloc = xloc.bar_time, style = htf_style,


width = htf_width, color = col))

hl.hi_label.unshift(label.new(time, n.ph, "P"+tf+"H", xloc = xloc.bar_time, style =


label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))

hl.lo_label.unshift(label.new(time, n.pl, "P"+tf+"L", xloc = xloc.bar_time, style =


label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))

hl.hit_high := false

hl.hit_low := false

if not sep_unlimited and hl.hi_line.size() > max_days

hl.hi_line.pop().delete()

hl.lo_line.pop().delete()

hl.hi_label.pop().delete()

hl.lo_label.pop().delete()

if hl.hi_line.size() > 0 and alert_HL

if not hl.hit_high and high > hl.hi_line.get(0).get_y1()

hl.hit_high := true

alert(str.format("Hit P{0}H", tf))

if not hl.hit_low and low < hl.lo_line.get(0).get_y1()

hl.hit_low := true

alert(str.format("Hit P{0}L", tf))


dwm() =>

if timeframe.in_seconds("") <= timeframe.in_seconds(tf_limit)

// DWM - Separators

dwm_sep("D", ds, d_sep_line, d_color)

dwm_sep("W", ws, w_sep_line, w_color)

dwm_sep("M", ms, m_sep_line, m_color)

// DWM - Open Lines

dwm_open("D", show_d_open, d_line, d_label, d_info, d_color)

dwm_open("W", show_w_open, w_line, w_label, w_info, w_color)

dwm_open("M", show_m_open, m_line, m_label, m_info, m_color)

// DWM - Highs and Lows

dwm_hl("D", dhl, d_hl, d_info, d_color)

dwm_hl("W", whl, w_hl, w_info, w_color)

dwm_hl("M", mhl, m_hl, m_info, m_color)

vline(bool use, bool t, line[] arr, color col) =>

if use

if t and not t[1]

arr.unshift(line.new(bar_index, high*1.0001, bar_index, low, style = vl_style, width =


vl_width, extend = extend.both, color = col))

if not v_unlimited

if arr.size() > max_days

arr.pop().delete()
vlines() =>

if timeframe.in_seconds("") <= timeframe.in_seconds(tf_limit)

vline(use_v1, t_v1, v1_line, v1_color)

vline(use_v2, t_v2, v2_line, v2_color)

vline(use_v3, t_v3, v3_line, v3_color)

vline(use_v4, t_v4, v4_line, v4_color)

hz_line(bool use, bool t, hz hz, string txt, color col) =>

if use

if t and not t[1]

hz.LN.unshift(line.new(bar_index, open, bar_index, open, style = hz_style, width =


hz_width, color = col))

hz.LB.unshift(label.new(bar_index, open, txt, style = label.style_label_left, color =


transparent, textcolor = txt_color, size = lbl_size))

array.unshift(hz.CO, false)

if not open_unlimited and hz.LN.size() > max_days

hz.LN.pop().delete()

hz.LB.pop().delete()

hz.CO.pop()

if not t and hz.CO.size() > 0

if not hz.CO.get(0)

hz.LN.get(0).set_x2(bar_index)

hz.LB.get(0).set_x(bar_index)

if (use_cutoff ? t_co : false)


hz.CO.set(0, true)

hz_lines() =>

if timeframe.in_seconds("") <= timeframe.in_seconds(tf_limit)

hz_line(use_h1, t_h1, hz_1, h1_text, h1_color)

hz_line(use_h2, t_h2, hz_2, h2_text, h2_color)

hz_line(use_h3, t_h3, hz_3, h3_text, h3_color)

hz_line(use_h4, t_h4, hz_4, h4_text, h4_color)

hz_line(use_h5, t_h5, hz_5, h5_text, h5_color)

hz_line(use_h6, t_h6, hz_6, h6_text, h6_color)

hz_line(use_h7, t_h7, hz_7, h7_text, h7_color)

hz_line(use_h8, t_h8, hz_8, h8_text, h8_color)

del_kz(kz k) =>

if k._box.size() > max_days

k._box.pop().delete()

if k._hi_line.size() > max_days

k._hi_line.pop().delete()

k._lo_line.pop().delete()

k._hi_valid.pop()

k._lo_valid.pop()

if show_midpoints

k._md_line.pop().delete()

k._md_valid.pop()
if k._hi_label.size() > max_days

k._hi_label.pop().delete()

k._lo_label.pop().delete()

update_price_string(label L, float P) =>

S = L.get_text()

pre = str.substring(S, 0, str.pos(S, " "))

str.trim(pre)

L.set_text(str.format("{0} ({1})", pre, P))

adjust_in_kz(kz kz, bool t) =>

if t

kz._box.get(0).set_right(time)

kz._box.get(0).set_top(math.max(kz._box.get(0).get_top(), high))

kz._box.get(0).set_bottom(math.min(kz._box.get(0).get_bottom(), low))

kz._range_current := kz._box.get(0).get_top() - kz._box.get(0).get_bottom()

if show_pivots and kz._hi_line.size() > 0

kz._hi_line.get(0).set_x2(time)

if high > kz._hi_line.get(0).get_y1()

kz._hi_line.get(0).set_xy1(time, high)

kz._hi_line.get(0).set_xy2(time, high)

kz._lo_line.get(0).set_x2(time)

if low < kz._lo_line.get(0).get_y1()


kz._lo_line.get(0).set_xy1(time, low)

kz._lo_line.get(0).set_xy2(time, low)

if show_midpoints

kz._md_line.get(0).set_x2(time)

kz._md_line.get(0).set_xy1(time, math.avg(kz._hi_line.get(0).get_y2(),
kz._lo_line.get(0).get_y2()))

kz._md_line.get(0).set_xy2(time, math.avg(kz._hi_line.get(0).get_y2(),
kz._lo_line.get(0).get_y2()))

if show_labels and kz._hi_label.size() > 0

if label_right

kz._hi_label.get(0).set_x(time)

kz._lo_label.get(0).set_x(time)

if high > kz._hi_label.get(0).get_y()

kz._hi_label.get(0).set_xy(time, high)

if label_price

update_price_string(kz._hi_label.get(0), high)

if low < kz._lo_label.get(0).get_y()

kz._lo_label.get(0).set_xy(time, low)

if label_price

update_price_string(kz._lo_label.get(0), low)

adjust_out_kz(kz kz, bool t) =>

if not t and kz._box.size() > 0

if t[1]
array.unshift(kz._range_store, kz._range_current)

if kz._range_store.size() > range_avg

kz._range_store.pop()

if kz._box.size() > 0 and show_pivots

for i = 0 to kz._box.size() - 1

if not ext_current or (ext_current and i == 0)

if ext_past ? true : (kz._hi_valid.get(i) == true)

kz._hi_line.get(i).set_x2(time)

if show_labels and label_right

kz._hi_label.get(i).set_x(time)

if high > kz._hi_line.get(i).get_y1() and kz._hi_valid.get(i) == true

if use_alerts and i == 0

alert("Broke "+kz._title+" High", alert.freq_once_per_bar)

kz._hi_valid.set(i, false)

if show_labels and label_right

kz._hi_label.get(0).set_style(label.style_label_down)

else if (use_cutoff ? t_co : false)

kz._hi_valid.set(i, false)

if ext_past ? true : (kz._lo_valid.get(i) == true)

kz._lo_line.get(i).set_x2(time)

if show_labels and label_right

kz._lo_label.get(i).set_x(time)

if low < kz._lo_line.get(i).get_y1() and kz._lo_valid.get(i) == true

if use_alerts and i == 0
alert("Broke "+kz._title+" Low", alert.freq_once_per_bar)

kz._lo_valid.set(i, false)

if show_labels and label_right

kz._lo_label.get(0).set_style(label.style_label_up)

else if (use_cutoff ? t_co : false)

kz._lo_valid.set(i, false)

if show_midpoints and not t

if stop_midpoints ? (kz._md_valid.get(i) == true) : true

kz._md_line.get(i).set_x2(time)

if kz._md_valid.get(i) == true and low <= kz._md_line.get(i).get_y1() and high >=


kz._md_line.get(i).get_y1()

kz._md_valid.set(i, false)

else

break

manage_kz(kz kz, bool use, bool t, color c, string box_txt, string hi_txt, string lo_txt) =>

if timeframe.in_seconds("") <= timeframe.in_seconds(tf_limit) and use

if t and not t[1]

_c = get_box_color(c)

_t = get_text_color(c)

kz._box.unshift(box.new(time, high, time, low, xloc = xloc.bar_time, border_color =


show_kz ? _c : na, bgcolor = show_kz ? _c : na, text = (show_kz and show_kz_text) ? box_txt :
na, text_color = _t))
if show_pivots

kz._hi_line.unshift(line.new(time, high, time, high, xloc = xloc.bar_time, style =


kzp_style, color = c, width = kzp_width))

kz._lo_line.unshift(line.new(time, low, time, low, xloc = xloc.bar_time, style = kzp_style,


color = c, width = kzp_width))

if show_midpoints

kz._md_line.unshift(line.new(time, math.avg(high, low), time, math.avg(high, low),


xloc = xloc.bar_time, style = kzm_style, color = c, width = kzm_width))

array.unshift(kz._md_valid, true)

array.unshift(kz._hi_valid, true)

array.unshift(kz._lo_valid, true)

if show_labels

_hi_txt = label_price ? str.format("{0} ({1})", hi_txt, high) : hi_txt

_lo_txt = label_price ? str.format("{0} ({1})", lo_txt, low) : lo_txt

if label_right

kz._hi_label.unshift(label.new(time, high, _hi_txt, xloc = xloc.bar_time, color =


transparent, textcolor = txt_color, style = label.style_label_left, size = lbl_size))

kz._lo_label.unshift(label.new(time, low, _lo_txt, xloc = xloc.bar_time, color =


transparent, textcolor = txt_color, style = label.style_label_left, size = lbl_size))

else

kz._hi_label.unshift(label.new(time, high, _hi_txt, xloc = xloc.bar_time, color =


transparent, textcolor = txt_color, style = label.style_label_down, size = lbl_size))

kz._lo_label.unshift(label.new(time, low, _lo_txt, xloc = xloc.bar_time, color =


transparent, textcolor = txt_color, style = label.style_label_up, size = lbl_size))

del_kz(kz)
adjust_in_kz(kz, t)

adjust_out_kz(kz, t)

manage_kz(as_kz, use_asia, t_as, as_color, as_txt, ash_str, asl_str)

manage_kz(lo_kz, use_london, t_lo, lo_color, lo_txt, loh_str, lol_str)

manage_kz(na_kz, use_nyam, t_na, na_color, na_txt, nah_str, nal_str)

manage_kz(nl_kz, use_nylu, t_nl, nl_color, nl_txt, nlh_str, nll_str)

manage_kz(np_kz, use_nypm, t_np, np_color, np_txt, nph_str, npl_str)

dwm()

vlines()

hz_lines()

new_dow_time = dow_xloc == 'Midday' ? time - timeframe.in_seconds("D") / 2 * 1000 : time

new_day = dayofweek(new_dow_time, gmt_tz) != dayofweek(new_dow_time, gmt_tz)[1]

var dow_top = dow_yloc == 'Top'

var saturday = "SATURDAY"

var sunday = "SUNDAY"

var monday = "MONDAY"

var tuesday = "TUESDAY"

var wednesday = "WEDNESDAY"

var thursday = "THURSDAY"

var friday = "FRIDAY"


plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 1
and new_day and not dow_hide_wknd, location = dow_top ? location.top : location.bottom,
char = "", textcolor = txt_color, text = sunday)

plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 2


and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor =
txt_color, text = monday)

plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 3


and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor =
txt_color, text = tuesday)

plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 4


and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor =
txt_color, text = wednesday)

plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 5


and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor =
txt_color, text = thursday)

plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 6


and new_day, location = dow_top ? location.top : location.bottom, char = "", textcolor =
txt_color, text = friday)

plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 7


and new_day and not dow_hide_wknd, location = dow_top ? location.top : location.bottom,
char = "", textcolor = txt_color, text = saturday)

get_min_days_stored() =>

store = array.new_int()

if as_kz._range_store.size() > 0

store.push(as_kz._range_store.size())

if lo_kz._range_store.size() > 0

store.push(lo_kz._range_store.size())

if na_kz._range_store.size() > 0

store.push(na_kz._range_store.size())
if nl_kz._range_store.size() > 0

store.push(nl_kz._range_store.size())

if np_kz._range_store.size() > 0

store.push(np_kz._range_store.size())

result = store.min()

set_table(table tbl, kz kz, int row, string txt, bool use, bool t, color col) =>

if use

table.cell(tbl, 0, row, txt, text_size = range_size, bgcolor = get_box_color(col), text_color =


txt_color)

table.cell(tbl, 1, row, str.tostring(kz._range_current), text_size = range_size, bgcolor = t ?


get_box_color(col) : na, text_color = txt_color)

if show_range_avg

table.cell(tbl, 2, row, str.tostring(kz._range_store.avg()), text_size = range_size, text_color


= txt_color)

if show_range and barstate.islast

var tbl = table.new(range_pos, 10, 10, chart.bg_color, chart.fg_color, 2, chart.fg_color, 1)

table.cell(tbl, 0, 0, "Killzone", text_size = range_size, text_color = txt_color)

table.cell(tbl, 1, 0, "Range", text_size = range_size, text_color = txt_color)

if show_range_avg

table.cell(tbl, 2, 0, "Avg ("+str.tostring(get_min_days_stored())+")", text_size = range_size,


text_color = txt_color)

set_table(tbl, as_kz, 1, as_txt, use_asia, t_as, as_color)

set_table(tbl, lo_kz, 2, lo_txt, use_london, t_lo, lo_color)


set_table(tbl, na_kz, 3, na_txt, use_nyam, t_na, na_color)

set_table(tbl, nl_kz, 4, nl_txt, use_nylu, t_nl, nl_color)

set_table(tbl, np_kz, 5, np_txt, use_nypm, t_np, np_color)

// ---------------------------------------- Core Logic --------------------------------------------------

CODE 4
//@version=5

indicator("HTF Candle Range Box with Breakout Confirmation", overlay=true)

// Inputs for two higher time frames.

htf_res = input.timeframe("15", title="First Higher Time Frame")

htf_res2 = input.timeframe("60", title="Second Higher Time Frame")

// ---------------

// FIRST HTF Block

// ---------------

// Retrieve the last fully closed candle’s data for the first timeframe.

c_high = request.security(syminfo.tickerid, htf_res, high[1],


lookahead=barmerge.lookahead_off)

c_low = request.security(syminfo.tickerid, htf_res, low[1],


lookahead=barmerge.lookahead_off)

c_close = request.security(syminfo.tickerid, htf_res, close[1],


lookahead=barmerge.lookahead_off)

c_open = request.security(syminfo.tickerid, htf_res, open[1],


lookahead=barmerge.lookahead_off)

// Retrieve the previous candle’s high and low.

p_high = request.security(syminfo.tickerid, htf_res, high[2],


lookahead=barmerge.lookahead_off)
p_low = request.security(syminfo.tickerid, htf_res, low[2],
lookahead=barmerge.lookahead_off)

// Determine if the candle broke the previous candle’s boundaries.

bool break_upper = c_high > p_high

bool break_lower = c_low < p_low

var color boxColor = color.orange

if break_upper and not break_lower

if c_close > p_high

boxColor := color.green

else

boxColor := color.red

else if break_lower and not break_upper

if c_close < p_low

boxColor := color.red

else

boxColor := color.green

else if break_upper and break_lower

if c_close > p_high

boxColor := color.green

else if c_close < p_low

boxColor := color.red

else

if c_open > p_high

boxColor := color.green
else if c_open < p_low

boxColor := color.red

else

boxColor := color.orange

else

boxColor := color.orange

// Get the start time of the current HTF candle.

htf_current_time = request.security(syminfo.tickerid, htf_res, time,


lookahead=barmerge.lookahead_off)

// Track the starting bar of the HTF candle.

var int htfStartBar = na

if na(htfStartBar)

htfStartBar := bar_index

// Variables to hold the drawn box and its label.

var box htfBox = na

var label tf1Label = na

// A flag to lock in confirmation once a breakout happens.

var bool confirmed_tf1 = false

// When a new HTF candle starts, delete the old box/label, draw a new one, and reset the
confirmation.

if ta.change(htf_current_time)

if not na(htfBox)
box.delete(htfBox)

if not na(tf1Label)

label.delete(tf1Label)

htfBox := box.new(htfStartBar, c_high, bar_index - 1, c_low,

border_color=boxColor, border_width=2,

bgcolor=color.new(boxColor, 85))

tf1Label := label.new(x=htfStartBar, y=c_high, text=htf_res,

style=label.style_label_left, color=color.new(boxColor, 0),

textcolor=color.white)

htfStartBar := bar_index

confirmed_tf1 := false

// ---------------

// SECOND HTF Block

// ---------------

// Retrieve the last fully closed candle’s data for the second timeframe.

c2_high = request.security(syminfo.tickerid, htf_res2, high[1],


lookahead=barmerge.lookahead_off)

c2_low = request.security(syminfo.tickerid, htf_res2, low[1],


lookahead=barmerge.lookahead_off)

c2_close = request.security(syminfo.tickerid, htf_res2, close[1],


lookahead=barmerge.lookahead_off)

c2_open = request.security(syminfo.tickerid, htf_res2, open[1],


lookahead=barmerge.lookahead_off)

// Retrieve the previous candle’s high and low.

p2_high = request.security(syminfo.tickerid, htf_res2, high[2],


lookahead=barmerge.lookahead_off)
p2_low = request.security(syminfo.tickerid, htf_res2, low[2],
lookahead=barmerge.lookahead_off)

// Determine if the candle broke the previous candle’s boundaries.

bool break_upper2 = c2_high > p2_high

bool break_lower2 = c2_low < p2_low

var color boxColor2 = color.orange

if break_upper2 and not break_lower2

if c2_close > p2_high

boxColor2 := color.green

else

boxColor2 := color.red

else if break_lower2 and not break_upper2

if c2_close < p2_low

boxColor2 := color.red

else

boxColor2 := color.green

else if break_upper2 and break_lower2

if c2_close > p2_high

boxColor2 := color.green

else if c2_close < p2_low

boxColor2 := color.red

else

if c2_open > p2_high

boxColor2 := color.green
else if c2_open < p2_low

boxColor2 := color.red

else

boxColor2 := color.orange

else

boxColor2 := color.orange

// Get the start time of the current HTF candle for the second timeframe.

htf_current_time2 = request.security(syminfo.tickerid, htf_res2, time,


lookahead=barmerge.lookahead_off)

// Track the starting bar of the second HTF candle.

var int htfStartBar2 = na

if na(htfStartBar2)

htfStartBar2 := bar_index

// Variables to hold the second drawn box and its label.

var box htfBox2 = na

var label tf2Label = na

// A flag to lock in confirmation for the second timeframe.

var bool confirmed_tf2 = false

// When a new candle starts on the second timeframe, update the box, label, and reset
confirmation.

if ta.change(htf_current_time2)

if not na(htfBox2)
box.delete(htfBox2)

if not na(tf2Label)

label.delete(tf2Label)

htfBox2 := box.new(htfStartBar2, c2_high, bar_index - 1, c2_low,

border_color=boxColor2, border_width=2,

bgcolor=color.new(boxColor2, 85))

tf2Label := label.new(x=htfStartBar2, y=c2_high, text=htf_res2,

style=label.style_label_left, color=color.new(boxColor2, 0),

textcolor=color.white)

htfStartBar2 := bar_index

confirmed_tf2 := false

// ---------------------------------------------

// Breakout Confirmation Logic for Both Timeframes

// ---------------------------------------------

// For the first timeframe: if the price goes above the HTF candle’s high or below its low, update
the box and label.

if not confirmed_tf1 and not na(htfBox)

if high > c_high

box.set_border_color(htfBox, color.green)

box.set_bgcolor(htfBox, color.new(color.green, 85))

if not na(tf1Label)

label.set_text(tf1Label, "Confirmed bullish")

confirmed_tf1 := true

else if low < c_low

box.set_border_color(htfBox, color.red)
box.set_bgcolor(htfBox, color.new(color.red, 85))

if not na(tf1Label)

label.set_text(tf1Label, "Confirmed bearish")

confirmed_tf1 := true

// For the second timeframe: similar logic applies.

if not confirmed_tf2 and not na(htfBox2)

if high > c2_high

box.set_border_color(htfBox2, color.green)

box.set_bgcolor(htfBox2, color.new(color.green, 85))

if not na(tf2Label)

label.set_text(tf2Label, "Confirmed bullish")

confirmed_tf2 := true

else if low < c2_low

box.set_border_color(htfBox2, color.red)

box.set_bgcolor(htfBox2, color.new(color.red, 85))

if not na(tf2Label)

label.set_text(tf2Label, "Confirmed bearish")

confirmed_tf2 := true

CODE 5
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/

// © Algoryze

//@version=5

indicator("Previous Day High and Low + Separators Daily/Weekly", overlay=true,


max_lines_count = 500, max_boxes_count = 500, max_labels_count = 500)
// Function to check if a new day has started

_isNewDay(utcOffsetInMs) =>

dow = dayofweek(time + utcOffsetInMs)

dayChanged = dow != dow[1]

dayChanged

// Function to check if a new week has started

_isNewWeek(utcOffsetInMs) =>

woy = weekofyear(time + utcOffsetInMs)

weekChanged = woy != woy[1]

weekChanged

_bottomMarkText(barTime, utcOffsetInMs) =>

var monthShortNames = array.from('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec')

var weekdayShortNames = array.from('', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')

weekdayShort = array.get(weekdayShortNames, dayofweek(barTime + utcOffsetInMs))

out = ''

+ weekdayShort

+ ' ' + str.tostring(dayofmonth(barTime + utcOffsetInMs))

+ ' ' + array.get(monthShortNames, month(barTime + utcOffsetInMs))

+ " '" + str.substring(str.tostring(year(barTime + utcOffsetInMs), '#'), 2)

+ ' ' + str.format_time(barTime, 'HH:mm')

// Function to get the highest and lowest prices of the previous day
_getPreviousDayHighLow(utcOffsetInMs) =>

dow = dayofweek(time + utcOffsetInMs)

var prevDayHigh = high

var prevDayHighTime = time

var prevDayLow = low

var prevDayLowTime = time

var dayHigh = high

var dayHighTime = time

var dayLow = low

var dayLowTime = time

if (dow != dow[1])

dayHigh := high

dayHighTime := time

dayLow := low

dayLowTime := time

prevDayHigh := dayHigh[1]

prevDayHighTime := dayHighTime[1]

prevDayLow := dayLow[1]

prevDayLowTime := dayLowTime[1]
else

if dayHigh < high

dayHigh := high

dayHighTime := time

if dayLow > low

dayLow := low

dayLowTime := time

[prevDayHigh, prevDayHighTime, prevDayLow, prevDayLowTime]

// Input for custom UTC offset

utcOffset = input.int(0, title="UTC Offset (in hours)", minval=-12, maxval=12)

utcOffsetInMs = utcOffset * 60 * 60 * 1000

// Daily separator inputs

var dailyGroup = 'Daily Separator'

dailySeparatorColor = input.color(color.orange, title='Color', group=dailyGroup)

dailySeparatorStyleInput = input.string('Solid', title='Style', options=['Solid', 'Dotted'],


display=display.none, group=dailyGroup)

dailySeparatorWidthInput = input.int(1, title='Width', minval=1, display=display.none,


group=dailyGroup)

dailySeparatorLabelTextColor = input.color(color.white, title='Label Text Color',


group=dailyGroup)

dailySeparatorStyle = dailySeparatorStyleInput == 'Solid' ? line.style_solid : line.style_dotted

// Weekly separator inputs


var weeklyGroup = 'Weekly Separator'

weeklySeparatorColorInput = input.color(color.gray, title='Color', group=weeklyGroup)

weeklySeparatorStyleInput = input.string('Solid', title='Style', options=['Solid', 'Dotted'],


display=display.none, group=weeklyGroup)

weeklySeparatorWidthInput = input.int(3, title='Width', minval=1, display=display.none,


group=weeklyGroup)

weeklySeparatorStyle = weeklySeparatorStyleInput == 'Solid' ? line.style_solid :


line.style_dotted

var prevDayHLGroup = 'Previous Day H&L'

prevDayHLColorInput = input.color(color.gray, title='Color', group=prevDayHLGroup)

prevDayHLTextColorInput = input.color(color.orange, title='Text Color', group=prevDayHLGroup)

prevDayHLStyleInput = input.string('Dotted', title='Style', options=['Solid', 'Dotted'],


display=display.none, group=prevDayHLGroup)

prevDayHLWidthInput = input.int(3, title='Width', minval=1, display=display.none,


group=prevDayHLGroup)

prevDayHLStyle = prevDayHLStyleInput == 'Solid' ? line.style_solid : line.style_dotted

var transpColor = color.new(color.white, 100)

var weekdayFullNames = array.from('', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',


'Friday', 'Saturday')

var box weekdayTopLabelBox = na

var box[] weekdayTopLabels = array.new_box(0)

var label[] weekdayBottomLabels = array.new_label(0)

var string periodD = "D"

var string periodW = "W"


var string periodM = "M"

var string periodY = "12M"

var int mult = timeframe.multiplier

var bool isHourly = timeframe.isminutes and mult % 60 == 0

var bool isMinuteLessThan30 = timeframe.isminutes and mult < 30

var string tfAuto =

timeframe.isseconds or isMinuteLessThan30 ? periodD :

isHourly ? periodW :

timeframe.isdaily ? periodM :

timeframe.isweekly or timeframe.ismonthly ? periodY :

periodW

pivotLevels = ta.pivot_point_levels('Traditional', timeframe.change(tfAuto))

pivot = array.get(pivotLevels, 0)

weekdayTopLabelBoxTop = array.get(pivotLevels, 5)

weekdayTopLabelBoxBottom = array.get(pivotLevels, 4)

weekdayBottomLabelLevel = array.get(pivotLevels, 6)

isNewPivot = pivot != pivot[1]

isNewDay = _isNewDay(utcOffsetInMs)

isNewWeek = _isNewWeek(utcOffsetInMs)

// Plot daily separator line

if isNewDay

weekdayFull = array.get(weekdayFullNames, dayofweek(time + utcOffsetInMs))


line.new(bar_index, low, bar_index, high, style=dailySeparatorStyle,
width=dailySeparatorWidthInput, color=dailySeparatorColor, extend=extend.both)

weekdayTopLabelBox := box.new(bar_index, weekdayTopLabelBoxTop, bar_index,


weekdayTopLabelBoxBottom, xloc=xloc.bar_index, bgcolor=transpColor,
border_color=transpColor, text=weekdayFull, text_color=dailySeparatorColor,
text_size=size.small, text_halign = text.align_center, text_valign = text.align_top)

array.push(weekdayTopLabels, weekdayTopLabelBox)

array.push(weekdayBottomLabels, label.new(bar_index, weekdayBottomLabelLevel,


text=_bottomMarkText(time, utcOffsetInMs), color=dailySeparatorColor,
textcolor=dailySeparatorLabelTextColor , style=label.style_label_up))

else

box.set_right(weekdayTopLabelBox, bar_index)

if isNewPivot and array.size(weekdayTopLabels) > 0

for i = 0 to array.size(weekdayTopLabels) - 1

box.set_top(array.get(weekdayTopLabels, i), weekdayTopLabelBoxTop)

box.set_bottom(array.get(weekdayTopLabels, i), weekdayTopLabelBoxBottom)

label.set_y(array.get(weekdayBottomLabels, i), weekdayBottomLabelLevel)

// Plot weekly separator line

if isNewWeek

line.new(bar_index, low, bar_index, high, color=weeklySeparatorColorInput,


style=weeklySeparatorStyle, width=weeklySeparatorWidthInput, extend=extend.both)

// Plot highest and lowest prices of the previous day

[prevDayHigh, prevDayHighTime, prevDayLow, prevDayLowTime] =


_getPreviousDayHighLow(utcOffsetInMs)

var line prevDayHighLine = line.new(time, prevDayHigh, time, prevDayHigh, xloc=xloc.bar_time,


color=prevDayHLColorInput, width=1)
var label prevDayHighLabel = label.new(time, prevDayHigh, xloc=xloc.bar_time, text='HOD',
color=transpColor, textcolor=prevDayHLTextColorInput, style=label.style_label_down)//,
style=label.style_label_lower_left)

var line prevDayLowLine = line.new(time, prevDayLow, time, prevDayLow, xloc=xloc.bar_time,


color=prevDayHLColorInput, width=1)

var label prevDayLowLabel = label.new(time, prevDayLow, xloc=xloc.bar_time, text='LOD',


color=transpColor, textcolor=prevDayHLTextColorInput, style=label.style_label_up)//,
style=label.style_label_upper_left)

if isNewDay

line.set_xy1(prevDayHighLine, prevDayHighTime, prevDayHigh)

line.set_xy2(prevDayHighLine, prevDayHighTime, prevDayHigh)

label.set_xy(prevDayHighLabel, prevDayHighTime, prevDayHigh)

line.set_xy1(prevDayLowLine, prevDayLowTime, prevDayLow)

line.set_xy2(prevDayLowLine, prevDayLowTime, prevDayLow)

label.set_xy(prevDayLowLabel, prevDayLowTime, prevDayLow)

else

t = time//chart.right_visible_bar_time

line.set_x2(prevDayHighLine, t)

label.set_x(prevDayHighLabel, t)

line.set_x2(prevDayLowLine, t)

label.set_x(prevDayLowLabel, t)

CODE 6
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-
NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version=5

indicator("SMT Divergences [LuxAlgo]", "LuxAlgo - SMT Divergences", overlay = true,


max_lines_count = 500, max_labels_count = 500)

//------------------------------------------------------------------------------

//Settings

//-----------------------------------------------------------------------------{

length = input.int(3, 'Pivot Lookback', minval = 2)

//Symbol A

useSym1 = input(true, 'Comparison Symbol', inline = 'symA')

sym1 = input.symbol('CME_MINI_DL:ES1!', '', inline = 'symA')

//Symbol B

useSym2 = input(true, 'Comparison Symbol', inline = 'symB')

sym2 = input.symbol('CBOT_MINI_DL:YM1!', '', inline = 'symB')

//Style

bullDivCss = input.color(#ff1100, 'Swing High', group = 'Style')

bearDivCss = input.color(#2157f3, 'Swing Low', group = 'Style')

//Dashboard

showDash = input(false, 'Show Dashboard' , group =


'Dashboard')

dashLoc = input.string('Top Right', 'Location', options = ['Top Right', 'Bottom Right', 'Bottom
Left'], group = 'Dashboard')
textSize = input.string('Small', 'Size' , options = ['Tiny', 'Small', 'Normal'] , group =
'Dashboard')

//-----------------------------------------------------------------------------}

//Function

//-----------------------------------------------------------------------------{

n = bar_index

get_hl() => [high, low, close]

//Swing highs divergences

get_divergence(ph, y2, sym_y2, css)=>

var float y1 = na

var float sym_y1 = na

var int x1 = na

var smt = 0

if y2 != y2[1] and sym_y2 != sym_y2[1]

//Test for SMT

if (y2 - y1) * (sym_y2 - sym_y1) < 0

line.new(n[length], y2, x1, y1, color = css)

smt += 1

sym_y1 := sym_y2

y1 := y2
x1 := n[length]

else if (ph and y2 > y2[1]) or (not ph and y2 < y2[1])

sym_y1 := na

y1 := y2

x1 := n[length]

smt

//-----------------------------------------------------------------------------}

//Main variables

//-----------------------------------------------------------------------------{

var phN = 0, var plN = 0

var ph_smt1 = 0.

var pl_smt1 = 0.

var ph_smt2 = 0.

var pl_smt2 = 0.

ticker1 = syminfo.ticker(sym1)

ticker2 = syminfo.ticker(sym2)

//-----------------------------------------------------------------------------}

//Detect swing highs/lows and divergences

//-----------------------------------------------------------------------------{

ph = fixnan(ta.pivothigh(length, length))

pl = fixnan(ta.pivotlow(length, length))

phN += ph != ph[1] ? 1 : 0
plN += pl != pl[1] ? 1 : 0

//Comparison symbol pivots

[h1, l1, c1] = request.security(sym1, timeframe.period, get_hl())

[h2, l2, c2] = request.security(sym2, timeframe.period, get_hl())

//Detect swing high divergences

if useSym1

sym_ph1 = fixnan(ta.pivothigh(h1, length, length))

sym_pl1 = fixnan(ta.pivotlow(l1, length, length))

ph_smt1 := get_divergence(true, ph, sym_ph1, bullDivCss)

pl_smt1 := get_divergence(false, pl, sym_pl1, bearDivCss)

if useSym2

sym_ph2 = fixnan(ta.pivothigh(h2, length, length))

sym_pl2 = fixnan(ta.pivotlow(l2, length, length))

ph_smt2 := get_divergence(true, ph, sym_ph2, bullDivCss)

pl_smt2 := get_divergence(false, pl, sym_pl2, bearDivCss)

txt = ''

if ph != ph[1]

if ph_smt1 > ph_smt1[1]

txt += ticker1

if ph_smt2 > ph_smt2[1]


txt += txt != '' ? ' | ' : ''

txt += ticker2

if txt != ''

label.new(n[length], ph, txt

, color = bullDivCss

, style = label.style_label_down

, textcolor = color.white

, size = size.tiny)

else

if pl_smt1 > pl_smt1[1]

txt += ticker1

if pl_smt2 > pl_smt2[1]

txt += txt != '' ? ' | ' : ''

txt += ticker2

if txt != ''

label.new(n[length], pl, txt

, color = bearDivCss

, style = label.style_label_up

, textcolor = color.white

, size = size.tiny)

//-----------------------------------------------------------------------------}

//Tables

//-----------------------------------------------------------------------------{
var table_position = dashLoc == 'Bottom Left' ? position.bottom_left

: dashLoc == 'Top Right' ? position.top_right

: position.bottom_right

var table_size = textSize == 'Tiny' ? size.tiny

: textSize == 'Small' ? size.small

: size.normal

var tb = table.new(table_position, 3, 3

, bgcolor = #1e222d

, border_color = #373a46

, border_width = 1

, frame_color = #373a46

, frame_width = 1)

if barstate.isfirst and showDash

tb.cell(1, 0, 'Swing High', text_color = color.white)

tb.cell(2, 0, 'Swing Low', text_color = color.white)

tb.cell(0, 1, ticker1, text_color = color.white)

tb.cell(0, 2, ticker2, text_color = color.white)

if barstate.islast and showDash

//Symbol 1

tb.cell(1, 1, str.format('{0} ({1, number, percent})', ph_smt1, ph_smt1 / phN)

, text_color = bullDivCss)
tb.cell(2, 1, str.format('{0} ({1, number, percent})', pl_smt1, pl_smt1 / plN)

, text_color = bearDivCss)

//Symbol 2

tb.cell(1, 2, str.format('{0} ({1, number, percent})', ph_smt2, ph_smt2 / phN)

, text_color = bullDivCss)

tb.cell(2, 2, str.format('{0} ({1, number, percent})', pl_smt2, pl_smt2 / plN)

, text_color = bearDivCss)

//-----------------------------------------------------------------------------}

CODE 7
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/

// © pmk07

//@version=5

indicator("MTF FVG", overlay=true, max_boxes_count = 500)

changelvl = input.bool(true, "Move box levels with price touch", group='General')

changecolor = input.bool(true, "Change box color with price touch", group='General')

extend_r = input.bool(true, "Extend boxes to the right", group='General')

plotLabel = input.bool(defval=false, title='Plot OB Label', inline='FVG label', group='Style')

LabelColor = input.color(defval=color.gray, title='Color', inline='FVG label', group='Style')

LabelSize = input.string(defval=size.tiny, title="Size", options=[size.huge, size.large, size.small,


size.tiny, size.auto, size.normal], inline='FVG label', group='Style')

BullColor = input.color(defval=color.new(color.green, 90), title='Bullish FVG Color', inline='Set


Custom Color', group='Style')
BearColor = input.color(defval=color.new(color.red, 90), title='Bearish FVG Color', inline='Set
Custom Color', group='Style')

BullColorTested = input.color(defval=color.new(color.gray, 90), title='Tested Bullish FVG Color',


inline='Set Custom Color', group='Style')

BearColorTested = input.color(defval=color.new(color.gray, 90), title='Tested Bearish FVG Color',


inline='Set Custom Color', group='Style')

var box[] bull_box = array.new_box()

var box[] bear_box = array.new_box()

tf1 = input.bool(false, "1", group='Timeframe')

tf2 = input.bool(false, "3", group='Timeframe')

tf3 = input.bool(false, "5", group='Timeframe')

tf4 = input.bool(true, "15", group='Timeframe')

tf5 = input.bool(false, "30", group='Timeframe')

tf6 = input.bool(false, "45", group='Timeframe')

tf7 = input.bool(true, "60", group='Timeframe')

tf8 = input.bool(false, "120", group='Timeframe')

tf9 = input.bool(false, "180", group='Timeframe')

tf10 = input.bool(true, "240", group='Timeframe')

tf11 = input.bool(true, "D", group='Timeframe')

tf12 = input.bool(true, "W", group='Timeframe')

find_box(t) =>

var int x = na

var float _top = na

var float _bottom = na


var int _time = na

if barstate.isconfirmed

x := low[2] >= high ? -1 : low >= high[2] ? 1 : 0

_top := x > 0 ? low : x < 0 ? low[2] : 0

_bottom := x > 0 ? high[2] : x < 0 ? high : 0

_time := time - t * 60000 * 2

[_time, _top, _bottom, x]

create_box(_time, _top, _bottom, x, TF) =>

_col = x > 0 ? BullColor : BearColor

_extend = extend_r ? extend.right : extend.none

_text = plotLabel ? TF : na

box boxOB = na

if x != 0

boxOB := box.new(left=_time, top=_top, right=time, extend=_extend , bottom=_bottom,


bgcolor=_col, border_color = na, text=_text, text_halign=text.align_right, text_size=LabelSize,
text_color=LabelColor, xloc = xloc.bar_time)

if x > 0

array.push(bull_box, boxOB)

if x < 0

array.push(bear_box, boxOB)

control_box(_boxes, bearbull) =>

if array.size(_boxes) > 0

for i = array.size(_boxes) - 1 to 0 by 1

_box = array.get(_boxes, i)

_boxLow = box.get_bottom(_box)
_boxHigh = box.get_top(_box)

if (bearbull > 0 and low < _boxLow) or (bearbull < 0 and high > _boxHigh)

box.delete(_box)

array.set(_boxes, i, na)

else

if bearbull > 0 and low < _boxHigh

if changelvl

box.set_top(_box, low)

if changecolor

box.set_bgcolor(_box, BullColorTested)

if bearbull < 0 and high > _boxLow

if changelvl

box.set_bottom(_box, high)

if changecolor

box.set_bgcolor(_box, BearColorTested)

box.set_right(_box, time)

if array.size(_boxes) > 0

for i = array.size(_boxes) - 1 to 0 by 1

if na(array.get(_boxes, i))

array.remove(_boxes, i)

[_time1, _top1, _bottom1, xtf1] = request.security(syminfo.tickerid, "1", find_box(1))

[_time2, _top2, _bottom2, xtf2] = request.security(syminfo.tickerid, "3", find_box(3))

[_time3, _top3, _bottom3, xtf3] = request.security(syminfo.tickerid, "5", find_box(5))

[_time4, _top4, _bottom4, xtf4] = request.security(syminfo.tickerid, "15", find_box(15))

[_time5, _top5, _bottom5, xtf5] = request.security(syminfo.tickerid, "30", find_box(30))


[_time6, _top6, _bottom6, xtf6] = request.security(syminfo.tickerid, "45", find_box(45))

[_time7, _top7, _bottom7, xtf7] = request.security(syminfo.tickerid, "60", find_box(60))

[_time8, _top8, _bottom8, xtf8] = request.security(syminfo.tickerid, "120", find_box(120))

[_time9, _top9, _bottom9, xtf9] = request.security(syminfo.tickerid, "180", find_box(180))

[_time10, _top10, _bottom10, xtf10] = request.security(syminfo.tickerid, "240", find_box(240))

[_time11, _top11, _bottom11, xtf11] = request.security(syminfo.tickerid, "D", find_box(1440))

[_time12, _top12, _bottom12, xtf12] = request.security(syminfo.tickerid, "W", find_box(10080))

if tf1 and timeframe.change("1")

create_box(_time1, _top1, _bottom1, xtf1, "1")

if tf2 and timeframe.change("3")

create_box(_time2, _top2, _bottom2, xtf2, "3")

if tf3 and timeframe.change("5")

create_box(_time3, _top3, _bottom3, xtf3, "5")

if tf4 and timeframe.change("15")

create_box(_time4, _top4, _bottom4, xtf4, "15")

if tf5 and timeframe.change("30")

create_box(_time5, _top5, _bottom5, xtf5, "30")

if tf6 and timeframe.change("45")

create_box(_time6, _top6, _bottom6, xtf6, "45")

if tf7 and timeframe.change("60")

create_box(_time7, _top7, _bottom7, xtf7, "60")

if tf8 and timeframe.change("120")

create_box(_time8, _top8, _bottom8, xtf8, "120")

if tf9 and timeframe.change("180")

create_box(_time9, _top9, _bottom9, xtf9, "180")


if tf10 and timeframe.change("240")

create_box(_time10, _top10, _bottom10, xtf10, "240")

if tf11 and timeframe.change("D")

create_box(_time11, _top11, _bottom11, xtf11, "D")

if tf12 and timeframe.change("W")

create_box(_time12, _top12, _bottom12, xtf12, "W")

control_box(bull_box, 1)

control_box(bear_box, -1)

CODE 8
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/

// © TFlab

//@version=5

indicator("FVG & IFVG ICT [TradingFinder] Inversion Fair Value Gap Signal" ,'Inversion FVG
TFlab', overlay = true, max_bars_back = 5000, max_boxes_count = 500,max_labels_count = 500,
max_lines_count = 500 )

//import Libraries

//import Order Block Drawing Library

import TFlab/OrderBlockDrawing_TradingFinder/3 as Drawing

//import FVG Library

import TFlab/FVGDetectorLibrary/3 as FVG

//import Alert Sender Library

import TFlab/AlertSenderLibrary_TradingFinder/1 as Alert

//import Switching Colors Theme

import TFlab/Dark_Light_Theme_TradingFinder_Switching_Colors_Library/1 as SC
//Input

//Global Setting

ShowAllFVG = input.bool(true, 'Show All FVG', group = 'Global Setting')

ShowAllIFVG = input.bool(true, 'Show All Inversion FVG', group = 'Global Setting')

FVGVaP = input.int(500, 'FVG & IFVG Validity Period (Bar)' , group = 'Logic Parameter' , maxval =
4998 , minval = 10,

tooltip = 'You can set the validity period of each FVG & IFVG based on the number of candles
that have passed since the origin of the Order Block.', group = 'Global Setting')

SCMode = input.string('Light', 'Switching Colors Theme Mode', options = ['Off', 'Light', 'Dark'])

//FVG

PShowDeFVG = input.bool(true, ' Show Bullish FVG', group = 'FVG',inline = 'DFVG')

PShowSuFVG = input.bool(true, ' Show Bearish FVG', group = 'FVG',inline = 'SFVG')

OCShowDeFVG = input.color(#4caf4f65, '', group = 'FVG',inline = 'DFVG')

OCShowSuFVG = input.color(#ff525291, '', group = 'FVG',inline = 'SFVG')

MLFVG = input.string('50 % OB' , 'Mitigation Level FVG', ['Proximal', '50 % OB', 'Distal'],

tooltip= 'Using this entry, you can determine which level the price reacts to in a FVG.', group =
'FVG')

PShowDeIFVG = input.bool(true, ' Show Bearish Inversion FVG', group = 'Inversion FVG',inline =
'IDFVG')

PShowSuIFVG = input.bool(true, ' Show Bullish Inversion FVG', group = 'Inversion FVG',inline =
'ISFVG')

OCShowDeIFVG = input.color(#ff52522f, '', group = 'Inversion FVG',inline = 'IDFVG')

OCShowSuIFVG = input.color(#4caf4f27, '', group = 'Inversion FVG',inline = 'ISFVG')

MLIFVG = input.string('50 % OB' , 'Mitigation Level IFVG', ['Proximal', '50 % OB', 'Distal'],

tooltip= 'Using this entry, you can determine which level the price reacts to in a Inversion FVG.',
group = 'Inversion FVG')
PFVGFilter = input.bool(true, 'FVG Filter ............', group = 'FVG' , inline = 'FVG Filter')

PFVGFilterType = input.string('Very Defensive', '',

['Very Aggressive' , 'Aggressive' , 'Defensive' , 'Very Defensive'], group = 'FVG', inline = 'FVG
Filter' ,

tooltip = 'If it is "On", this filter will filter "FVGs" based on the width of the Zone.' +

'From "Very Aggressive" to "Very Defensive" the width of the "FVG" decreases.')

AlertName = input.string('FVG & IFVG Inversion [TradingFinder]', 'Alerts Name', group = 'Alert')

Alert_FVG = input.string('On' , 'Alert FVG Mitigation' , ['On', 'Off'], 'If you turn on the Alert FVG
Mitigation,' +

'you can receive alerts and notifications after setting the "Alert".' , group = 'Alert')

Alert_IFVG = input.string('On' , 'Alert Inversion FVG Mitigation' , ['On', 'Off'], 'If you turn on the
Alert Inversion FVG Mitigation,' +

'you can receive alerts and notifications after setting the "Alert".' , group = 'Alert')

Frequncy = input.string('Once Per Bar' , 'Message Frequency' , ['All', 'Once Per Bar' , 'Per Bar
Close'], 'The triggering frequency. Possible values are: All'+

' (all function calls trigger the alert), Once Per Bar (the first function call during the bar triggers
the alert), ' +

' Per Bar Close (the function call triggers the alert only when it occurs during the last script
iteration of the real-time bar,' +

' when it closes). The default is alert.freq_once_per_bar.)', group = 'Alert')


UTC = input.string('UTC' , 'Show Alert time by Time Zone', group = 'Alert')

MoreInfo = input.string('On', 'Display More Info', ['On', 'Off'], group = 'Alert')

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

///////////////SCT///////////////

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

[CShowDeFVG] = SC.SwitchingColorMode(OCShowDeFVG , SCMode)

[CShowSuFVG] = SC.SwitchingColorMode(OCShowSuFVG , SCMode)

[CShowDeIFVG] = SC.SwitchingColorMode(OCShowDeIFVG , SCMode)

[CShowSuIFVG] = SC.SwitchingColorMode(OCShowSuIFVG , SCMode)

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

///////////////FVG///////////////

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

[DConditionFVG, DDFVG, DPFVG, BarDFVG, SConditionFVG, SDFVG, SPFVG, BarSFVG] =


FVG.FVGDetector(PFVGFilter ? 'On' : 'Off', PFVGFilterType, false, false)

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

///////////////Drawing///////////////

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

//OUTPUT ==> Alert Trigger

[Alert_DFVG, Alert_DIFVG] = Drawing.OBDrawing('Demand', DConditionFVG,DDFVG, DPFVG,


BarDFVG, true, FVGVaP, MLFVG, MLIFVG, ShowAllFVG, ShowAllIFVG, PShowDeFVG,
PShowDeIFVG, CShowDeFVG, CShowDeIFVG)
[Alert_SFVG, Alert_SIFVG] = Drawing.OBDrawing('Supply', SConditionFVG, SDFVG, SPFVG,
BarSFVG, true, FVGVaP, MLFVG, MLIFVG, ShowAllFVG, ShowAllIFVG, PShowSuFVG,
PShowSuIFVG, CShowSuFVG, CShowSuIFVG)

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

///////////////Alert///////////////

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

Alert.AlertSender(Alert_DFVG , Alert_FVG, AlertName, 'Bullish', 'Order Block Signal',


'Full' ,Frequncy, UTC, MoreInfo, 'Long Position in Bullish FVG', open, high, low, close,0,0,0,
DDFVG , DPFVG)

Alert.AlertSender(Alert_DIFVG , Alert_IFVG, AlertName, 'Bearish', 'Order Block Signal',


'Full' ,Frequncy, UTC, MoreInfo, 'Short Position in Bearish IFVG', open, high, low, close,0,0,0,
DPFVG , DDFVG)

Alert.AlertSender(Alert_SFVG , Alert_FVG, AlertName, 'Bearish', 'Order Block Signal',


'Full' ,Frequncy, UTC, MoreInfo, 'Short Position in Bearish FVG', open, high, low, close,0,0,0,
SDFVG , SPFVG)

Alert.AlertSender(Alert_SIFVG , Alert_IFVG, AlertName, 'Bullish', 'Order Block Signal',


'Full' ,Frequncy, UTC, MoreInfo, 'Long Position in Bullish IFVG', open, high, low, close,0,0,0,
SPFVG , SDFVG)

CODE 9
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-
NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/

// © LuxAlgo

//@version=5

indicator( 'Liquidity Sweeps [LuxAlgo]'

, 'LuxAlgo - Liquidity Sweeps'


, max_lines_count=500

, max_boxes_count=500

, overlay=true

//------------------------------------------------------------------------------

//Settings

//-----------------------------------------------------------------------------{

len = input.int(5, 'Swings', minval=1, group='Liquidity Sweeps')

opt = input.string('Only Wicks', 'options'

, options=['Only Wicks', 'Only Outbreaks & Retest', 'Wicks + Outbreaks & Retest'],
group='Liquidity Sweeps')

colBl = input.color(#089981, 'Bull ', group='Liquidity Sweeps', inline='c1')

colBr = input.color(#f23645, 'Bear' , group='Liquidity Sweeps', inline='c2')

colBl2 = input.color(#08998180, '' , group='Liquidity Sweeps', inline='c1')

colBr2 = input.color(#f2364580, '' , group='Liquidity Sweeps', inline='c2')

extend = input.bool(true, 'Extend', group='Sweep Area')

maxB = input.int(300, 'Max bars', minval=1, maxval=5000, group='Sweep Area')

colBl3 = input.color(#08998141, 'Bull ', group='Sweep Area')

colBr3 = input.color(#f2364541, 'Bear' , group='Sweep Area')

oW = opt == 'Only Wicks'

oO = opt == 'Only Outbreaks & Retest'

WO = opt == 'Wicks + Outbreaks & Retest'


n = bar_index

//-----------------------------------------------------------------------------}

//UDT's

//-----------------------------------------------------------------------------{

type piv

float prc // price

int bix // bar_index

bool brk // broken

bool mit // mitigated

bool tak // taken

bool wic // wick

line lin

type boxBr

box bx

line ln

bool br

int dr

//-----------------------------------------------------------------------------}

//Variables

//-----------------------------------------------------------------------------{

var array< piv >aPivH = array.new< piv >(1, piv.new ())

var array< piv >aPivL = array.new< piv >(1, piv.new ())


var array<boxBr>aBoxBr = array.new<boxBr>(1, boxBr.new())

//-----------------------------------------------------------------------------}

//Methods - functions

//-----------------------------------------------------------------------------{

method n(float piv) => bool out = not na(piv)

method p(piv piv, float val) => float out = (100 / piv.prc * val) - 100

method l(piv get, color c, string s='sd') =>

style = switch s

'dt' => line.style_dotted

'ds' => line.style_dashed

=> line.style_solid

line.new(get.bix, get.prc, n, get.prc, color=c, style = style)

method br(piv get, color c3, color c, int d) =>

y1 = d == 1 ? high : get.prc

y2 = d == 1 ? get.prc : low

boxBr.new(

box.new(n -1, y1, n +1, y2

, border_color

= color.new(

na, na )

, bgcolor=c3)

, line.new(n , y1, n, y2, color=c, width=3)


, false

, d)

lnDot(y, c) => line.new(n, y, n+3, y, color=c, style=line.style_dotted)

//-----------------------------------------------------------------------------}

//Execution

//-----------------------------------------------------------------------------{

ph = ta.pivothigh(len, len)

pl = ta.pivotlow (len, len)

if ph.n()

aPivH.unshift(piv.new(ph, n -len, false, false, false, false))

if pl.n()

aPivL.unshift(piv.new(pl, n -len, false, false, false, false))

for i = aPivH.size() -1 to 0

get = aPivH.get(i)

if not get.mit

if not get.brk

if close > get.prc

if not oW

get.brk := true

else

get.mit := true
if not oO and not get.wic

if high > get.prc and close < get.prc

aBoxBr.unshift(get.br(colBr3, colBr, 1))

get.l(colBr2, 'dt'), lnDot(low, colBr)

get.wic := true

else

if close < get.prc

get.mit := true

if not oW and low < get.prc and close > get.prc

aBoxBr.unshift(get.br(colBl3, colBl, -1))

get.l(colBl2, 'ds'), lnDot(high, colBl)

get.tak := true

if n - get.bix > 2000 or get.mit or get.tak

aPivH.remove(i).lin.delete()

for i = aPivL.size() -1 to 0

get = aPivL.get(i)

if not get.mit

if not get.brk

if close < get.prc

if not oW

get.brk := true

else

get.mit := true

if not oO and not get.wic


if low < get.prc and close > get.prc

aBoxBr.unshift(get.br(colBl3, colBl, -1))

get.l(colBl2, 'dt'), lnDot(high, colBl)

get.wic := true

else

if close > get.prc

get.mit := true

if not oW and high > get.prc and close < get.prc

aBoxBr.unshift(get.br(colBr3, colBr, 1))

get.l(colBr2, 'ds'), lnDot(low, colBr)

get.tak := true

if n - get.bix > 2000 or get.mit or get.tak

aPivL.remove(i).lin.delete()

if extend

for bx in aBoxBr

if not bx.br and n - bx.bx.get_left() -1 <= maxB

bx.bx.set_right(bar_index)

if bx.dr == -1 and close < bx.bx.get_bottom()

bx.br := true

if bx.dr == 1 and close > bx.bx.get_top ()

bx.br := true

//-----------------------------------------------------------------------------}

You might also like