n = bar_index maxSize = 250 minT = syminfo.mintick
//------------------------------------------------------------------------------ //UDT's //-----------------------------------------------------------------------------{ type piv int b float p bool br
//Silver Bullet Periods SB_LN_per = "Europe/Moscow".timeSess("1100-1200") // period/session ~ The London Open Silver Bullet (11 AM — 12 PM Moscow time) SB_AM_per = "Europe/Moscow".timeSess("1800-1900") // period/session ~ The AM Session Silver Bullet (6 PM — 7 PM Moscow time) SB_PM_per = "Europe/Moscow".timeSess("2200-2300") // period/session ~ The PM Session Silver Bullet (10 PM — 11 PM Moscow time)
is_in_SB = SB_LN_per or SB_AM_per or SB_PM_per strSB = is_in_SB and not is_in_SB [1] strLN = SB_LN_per and not SB_LN_per[1] strAM = SB_AM_per and not SB_AM_per[1] strPM = SB_PM_per and not SB_PM_per[1] endSB = not is_in_SB and is_in_SB [1] endLN = not SB_LN_per and SB_LN_per[1] endAM = not SB_AM_per and SB_AM_per[1] endPM = not SB_PM_per and SB_PM_per[1]
if start hilo.set(0, 0 ) hilo.set(1, 10e6) if stricty ? not keep : true
while highs.size() > 0 get=highs.pop() get.ln.delete() while lows.size() > 0 get= lows.pop() get.ln.delete() while targHi.size() > 0 targHi.pop().delete() while targLo.size() > 0 targLo.pop().delete()
while a.GN_targHi.size() > 0 a.GN_targHi.pop().delete() while a.LN_targHi.size() > 0 a.LN_targHi.pop().delete() while a.AM_targHi.size() > 0 a.AM_targHi.pop().delete() while a.PM_targHi.size() > 0 a.PM_targHi.pop().delete()
while a.GN_targLo.size() > 0 a.GN_targLo.pop().delete() while a.LN_targLo.size() > 0 a.LN_targLo.pop().delete() while a.AM_targLo.size() > 0 a.AM_targLo.pop().delete() while a.PM_targLo.size() > 0 a.PM_targLo.pop().delete()
if active hilo.set(0, math.max(hilo.get(0), high)) hilo.set(1, math.min(hilo.get(1), low ))
if ph if ph > mxPiv mxPiv := ph if swingH.size() > 0 for i = swingH.size() -1 to 0 get = swingH.get(i) if ph >= get.p swingH.remove(i) swingH.unshift(piv.new(n -1, ph))
if str == 'GN' or str == 'LN' dir = aZZ.d.get (0) x1 = aZZ.x.get (0) y1 = aZZ.y.get (0) y2 = nz(high[1]) // if dir < 1 // if previous point was a pl, add, and change direction ( 1) aZZ.in_out( 1, x1, y1, x2, y2) else if dir == 1 and ph > y1 aZZ.x.set(0, x2), aZZ.y.set(0, y2) if showZZ aZZ.l.get(0).set_xy2 (x2 , y2) if pl if pl < mnPiv mnPiv := pl if swingL.size() > 0 for i = swingL.size() -1 to 0 get = swingL.get(i) if pl <= get.p swingL.remove(i) swingL.unshift(piv.new(n -1, pl)) // if str == 'GN' or str == 'LN' dir = aZZ.d.get (0) x1 = aZZ.x.get (0) y1 = aZZ.y.get (0) y2 = nz(low [1]) // if dir > -1 // if previous point was a ph, add, and change direction (-1) aZZ.in_out(-1, x1, y1, x2, y2) else if dir == -1 and pl < y1 aZZ.x.set(0, x2), aZZ.y.set(0, y2) if showZZ aZZ.l.get(0).set_xy2 (x2 , y2) // iH = aZZ.d.get(2) == 1 ? 2 : 1 iL = aZZ.d.get(2) == -1 ? 2 : 1 // switch // MSS Bullish close > aZZ.y.get(iH) and aZZ.d.get(iH) == 1 and MSS_dir < 1 => MSS_dir := 1 if active and showT line.new(aZZ.x.get(iH), aZZ.y.get(iH), n, aZZ.y.get(iH), color=cResLine, width=2)
// MSS Bearish close < aZZ.y.get(iL) and aZZ.d.get(iL) == -1 and MSS_dir > -1 => MSS_dir := -1 if active and showT line.new(aZZ.x.get(iL), aZZ.y.get(iL), n, aZZ.y.get(iL), color=cSupLine, width=2)
if end sz = swingH.size() if sz > 0 for i = 0 to sz -1 y = swingH.get(i).p if y > (stricty ? min : hilo.get(0)) targHi.unshift(line.new(swingH.get(i).b, y, n, y, color=cResLine)) highs.unshift(actLine.new(line.new( n, y, n, y, color=cResLine), true))
sz := swingL.size() if sz > 0 for i = 0 to sz -1 y = swingL.get(i).p if y < (stricty ? max : hilo.get(1)) targLo.unshift(line.new(swingL.get(i).b, y, n, y, color=cSupLine)) lows.unshift(actLine.new(line.new( n, y, n, y, color=cSupLine), true))
swingH.clear() swingL.clear()
mnPiv := 10e6 mxPiv := 0
if showZZ if ph or pl aZZ.l.get(0).set_color(MSS_dir == 1 ? cResLine : cSupLine)
hSz = highs.size() if hSz > 200 highs.pop().ln.delete()
hSz := highs.size()
if hSz > 0 for i = 0 to hSz -1 get = highs.get(i) if get.active get.ln.set_x2(n) if high > get.ln.get_y2() get.active := false targetHi := true lSz = lows.size() if lSz > 200 lows.pop().ln.delete()
lSz := lows.size()
if lSz > 0 for i = 0 to lSz -1 get = lows.get(i) if get.active get.ln.set_x2(n) if low < get.ln.get_y2() get.active := false targetLo := true
if showSB l_SB.unshift(line.new(n, close, n, close + minT , color= col_SB, extend=extend.both))
for i = 0 to bFVG_bull.size ( ) -1 get = bFVG_bull.get (i) if n > get.box.get_right( ) -1 if get.current == true get.current := false for i = 0 to bFVG_bear.size ( ) -1 get = bFVG_bear.get (i) if n > get.box.get_right( ) -1 if get.current == true get.current := false
//FVG's if is_in_SB trend := aTrend.get(0) if iTrend switch trend //bullish 1 => if low > high[2] bFVG_bull.unshift( FVG.new( box = box.new( n-2, low, n, high[2] ,border_color=color(na) ,bgcolor = cBullFVG) , active = false , current = true ) ) //bearish => if high < low [2] bFVG_bear.unshift( FVG.new( box = box.new( n-2, low[2], n, high ,border_color=color(na) ,bgcolor = cBearFVG) , active = false , current = true ) ) else if low > high[2] bFVG_bull.unshift( FVG.new( box = box.new( n , low, n, high[2] ,border_color=color(na) ,bgcolor = cBullFVG) , active = false , current = true ) )
if high < low [2] bFVG_bear.unshift( FVG.new( box = box.new( n , low[2], n, high ,border_color=color(na) ,bgcolor = cBearFVG) , active = false , current = true ) )
if endSB if showSB l_SB.unshift(line.new(n, close, n, close + minT , color= col_SB, extend=extend.both))
if bFVG_bull.size() > 0 for i = 0 to bFVG_bull.size ( ) -1 get = bFVG_bull.get (i) bLeft = get. box.get_left ( ) bTop = get. box.get_top ( ) bBot = get. box.get_bottom( ) if n - bLeft < 1000 if get.current if is_in_SB if close < bBot if superstrict get.current := false get.box.set_bgcolor(color.new(color.blue, 100)) get.box.set_right(bLeft) if superstrict or strict get.active := false else if extend if get.active //update right when extend get.box.set_right(n) //trigger retrace -> activated if not get.active if low < bTop and close > bBot get.active := true if extend get.box.set_right(n) //if last bar of session and no retrace or close < bottom -> FVG invisible if endSB if get.active if strict if close < bBot // needs to be above box bottom get.active := false if superstrict if close < bTop // needs to be above box top get.active := false //All FVG's who are not retraced (activated) are made invisible if not get.active get.box.set_bgcolor(color.new(color.blue, 100)) get.box.set_right(bLeft)
if get.active min := math.min(min, bBot + minimum_trade_framework) if extend get.box.set_right(n)
if endSB[1] get.active := false //if show_minFr // minTrFr.set_xy1(n -1, min - minimum_trade_framework) // minTrFr.set_xy2(n -1, min )
if bFVG_bear.size() > 0 for i = 0 to bFVG_bear.size ( ) -1 get = bFVG_bear.get (i) bLeft = get.box. get_left ( ) bTop = get.box. get_top ( ) bBot = get.box. get_bottom( ) if n - bLeft < 1000 if get.current if is_in_SB if close > bTop if superstrict get.current := false get.box.set_bgcolor(color.new(color.blue, 100)) get.box.set_right(bLeft) if superstrict or strict get.active := false else // if close < bTop if extend if get.active //update right when extend get.box.set_right(n) //trigger retrace -> activated if not get.active if high > bBot and close < bTop get.active := true if extend get.box.set_right(n) //if last bar of session and no retrace -> FVG invisible if endSB if get.active if strict if close > bTop // needs to be below box top get.active := false if superstrict if close > bBot // needs to be below box bottom get.active := false //All FVG's who are not retraced (activated) are made invisible if not get.active get.box.set_bgcolor(color.new(color.blue, 100)) get.box.set_right(bLeft)
if get.active max := math.max(max, bTop - minimum_trade_framework) if extend get.box.set_right(n)
if endSB[1] get.active := false //if show_minFr // maxTrFr.set_xy1(n -1, max ) // maxTrFr.set_xy2(n -1, max + minimum_trade_framework)
if barstate.islast if timeframe.in_seconds(timeframe.period) > 15 * 60 table.cell(tab, 0, 0, text = 'Please use a timeframe <= 15 minutes', text_color=#FF0000)
//-------------------------------------------}
Script protegido
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.