Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © Vulnerable_human_x
- //@version=5
- indicator("MTF - Volume Imbalances by EtherMatt", shorttitle = "MTF-VIB", overlay=true)
- //Volume Imbalance
- var g_vib = "=====> VOLUME IMBALANCE SETTINGS <====="
- var g_vis = "=====> DISPLAY SETTINGS <====="
- //Tooltip Strings
- string s_res = "Set the Timeframe for Volume Imbalances (Enable Extend All)"
- string s_max = "Set the maximum amount of Volume Imbalances to be displayed"
- string s_col = "Set the Volume Imbalance Color and Border Width (100 => No Borders)"
- string s_dis = 'Turn Volume Imbalances On/Off'
- string s_ext = 'Extends the Volume Imbalances until "Filled"'
- string s_all = 'Extends ALL Volume Imbalances until NOW'
- //Inputs
- res = input.timeframe(title='Volume Imbalances Timeframe', defval='5', group=g_vib, tooltip=s_res)
- maxVIB = input.int(defval=10, title="Volume Imbalances Displayed", minval=1, maxval=100, group=g_vib, tooltip=s_max)
- colorVIB = input.color(color.new(color.orange,60), "Volume Imbalances Color", group=g_vib, inline="1")
- bTrans = input.int(defval=80, title='', minval=0, maxval=100, group=g_vib, inline="1", tooltip=s_col)
- showVIB = input.bool(true, "Show Volume Imbalances?", group=g_vis, tooltip=s_dis)
- extendVIB = input.bool(true, title="Extend Volume Imbalances?", group=g_vis, tooltip=s_ext)
- extendAllVIB = input.bool(false,title="Extend all Volume Imbalances?", group=g_vis, tooltip=s_all)
- versioninput = input.string(defval='1.0', options=['1.0'], group='MADE WITH ❤️', title='🤖 MTF Volume Imbalances Version', tooltip='MTF Volume Imbalances 🚀 \nPropose new features you want to see! \nContact me on Discord @EtherMatt')
- o = request.security(syminfo.tickerid, res, open)
- c = request.security(syminfo.tickerid, res, close)
- h = request.security(syminfo.tickerid, res, high)
- l = request.security(syminfo.tickerid, res, low)
- //Variables for Boxes
- var int _fvg = 2
- var int _VIB = 3
- var box[] _upVIB = array.new_box()
- var box[] _downVIB = array.new_box()
- //Control Box 1
- filterVIB = bool(false)
- filterColorVIB = color(color.new(color.gray, 80))
- _controlBox(_boxes, _high, _low, _type) =>
- 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)
- _boxRight = box.get_right(_box)
- if (filterVIB and _type == _fvg)
- if na or (bar_index == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
- box.set_right(_box, bar_index + 1)
- else
- if _type == _fvg
- box.set_bgcolor(_box, filterVIB)
- box.set_border_color(_box, filterVIB)
- else
- if na or (bar_index == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
- box.set_right(_box, bar_index + 1)
- //Control Box 2
- _controlBox2(_boxes, _high, _low, _type) =>
- 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)
- _boxRight = box.get_right(_box)
- if extendAllVIB
- box.set_right(_box, bar_index + 1)
- //Volume Imbalance Up
- if showVIB and o > c[1] and l <= h[1] and c > c[1] and o > o[1]
- box _bullboxVI = na
- _bullboxVI := box.new(left=bar_index-1, top=math.min(o,c), right=bar_index+1, bottom=math.max(c[1],o[1]), bgcolor=colorVIB, border_color=color.new(colorVIB,bTrans))
- if array.size(_upVIB) > maxVIB
- box.delete(array.shift(_upVIB))
- array.push(_upVIB, _bullboxVI)
- //Volume Imbalance Down
- if showVIB and o < c[1] and o < o[1] and h >= l[1] and c < c[1] and c < o[1]
- box _bearboxVI = na
- _bearboxVI := box.new(left=bar_index-1, top=math.min(c[1],o[1]), right=bar_index+1, bottom=math.max(o,c), bgcolor=colorVIB, border_color=color.new(colorVIB,bTrans))
- if array.size(_downVIB) > maxVIB
- box.delete(array.shift(_downVIB))
- array.push(_downVIB, _bearboxVI)
- _controlBox2(_upVIB,h,l,_fvg)
- _controlBox2(_downVIB,h,l,_fvg)
- //Extend VIB
- if array.size(_upVIB) > 0 and extendVIB
- for i = array.size(_upVIB) - 1 to 0 by 1
- _box = array.get(_upVIB, i)
- _boxLow = box.get_bottom(_box)
- _boxHigh = box.get_top(_box)
- _boxRight = box.get_right(_box)
- if l > _boxHigh and bar_index == _boxRight
- box.set_right(_box, bar_index + 1)
- else
- if l <= _boxHigh and bar_index == _boxRight and filterVIB
- box.set_bgcolor(_box, filterColorVIB)
- box.set_border_color(_box, filterColorVIB)
- //Extend VIB
- if array.size(_downVIB) > 0 and extendVIB
- for i = array.size(_downVIB) - 1 to 0 by 1
- _box = array.get(_downVIB, i)
- _boxLow = box.get_bottom(_box)
- _boxHigh = box.get_top(_box)
- _boxRight = box.get_right(_box)
- if h < _boxHigh and bar_index == _boxRight
- box.set_right(_box, bar_index + 1)
- else
- if h >= _boxHigh and bar_index == _boxRight and filterVIB
- box.set_bgcolor(_box, filterColorVIB)
- box.set_border_color(_box, filterColorVIB)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement