Advertisement
xmd79

MTF - Volume Imbalances by EtherMatt

Jan 15th, 2023
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.44 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © Vulnerable_human_x
  3.  
  4. //@version=5
  5. indicator("MTF - Volume Imbalances by EtherMatt", shorttitle = "MTF-VIB", overlay=true)
  6.  
  7. //Volume Imbalance
  8. var g_vib = "=====> VOLUME IMBALANCE SETTINGS <====="
  9. var g_vis = "=====> DISPLAY SETTINGS <====="
  10.  
  11. //Tooltip Strings
  12. string s_res = "Set the Timeframe for Volume Imbalances (Enable Extend All)"
  13. string s_max = "Set the maximum amount of Volume Imbalances to be displayed"
  14. string s_col = "Set the Volume Imbalance Color and Border Width (100 => No Borders)"
  15. string s_dis = 'Turn Volume Imbalances On/Off'
  16. string s_ext = 'Extends the Volume Imbalances until "Filled"'
  17. string s_all = 'Extends ALL Volume Imbalances until NOW'
  18.  
  19. //Inputs
  20. res = input.timeframe(title='Volume Imbalances Timeframe', defval='5', group=g_vib, tooltip=s_res)
  21. maxVIB = input.int(defval=10, title="Volume Imbalances Displayed", minval=1, maxval=100, group=g_vib, tooltip=s_max)
  22. colorVIB = input.color(color.new(color.orange,60), "Volume Imbalances Color", group=g_vib, inline="1")
  23. bTrans = input.int(defval=80, title='', minval=0, maxval=100, group=g_vib, inline="1", tooltip=s_col)
  24. showVIB = input.bool(true, "Show Volume Imbalances?", group=g_vis, tooltip=s_dis)
  25. extendVIB = input.bool(true, title="Extend Volume Imbalances?", group=g_vis, tooltip=s_ext)
  26. extendAllVIB = input.bool(false,title="Extend all Volume Imbalances?", group=g_vis, tooltip=s_all)
  27.  
  28. 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')
  29.  
  30. o = request.security(syminfo.tickerid, res, open)
  31. c = request.security(syminfo.tickerid, res, close)
  32. h = request.security(syminfo.tickerid, res, high)
  33. l = request.security(syminfo.tickerid, res, low)
  34.  
  35. //Variables for Boxes
  36. var int _fvg = 2
  37. var int _VIB = 3
  38. var box[] _upVIB = array.new_box()
  39. var box[] _downVIB = array.new_box()
  40.  
  41. //Control Box 1
  42. filterVIB = bool(false)
  43. filterColorVIB = color(color.new(color.gray, 80))
  44. _controlBox(_boxes, _high, _low, _type) =>
  45. if array.size(_boxes) > 0
  46. for i = array.size(_boxes) - 1 to 0 by 1
  47. _box = array.get(_boxes, i)
  48. _boxLow = box.get_bottom(_box)
  49. _boxHigh = box.get_top(_box)
  50. _boxRight = box.get_right(_box)
  51. if (filterVIB and _type == _fvg)
  52. if na or (bar_index == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
  53. box.set_right(_box, bar_index + 1)
  54. else
  55. if _type == _fvg
  56. box.set_bgcolor(_box, filterVIB)
  57. box.set_border_color(_box, filterVIB)
  58. else
  59. if na or (bar_index == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
  60. box.set_right(_box, bar_index + 1)
  61.  
  62. //Control Box 2
  63. _controlBox2(_boxes, _high, _low, _type) =>
  64. if array.size(_boxes) > 0
  65. for i = array.size(_boxes) - 1 to 0 by 1
  66. _box = array.get(_boxes, i)
  67. _boxLow = box.get_bottom(_box)
  68. _boxHigh = box.get_top(_box)
  69. _boxRight = box.get_right(_box)
  70. if extendAllVIB
  71. box.set_right(_box, bar_index + 1)
  72.  
  73.  
  74. //Volume Imbalance Up
  75. if showVIB and o > c[1] and l <= h[1] and c > c[1] and o > o[1]
  76. box _bullboxVI = na
  77. _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))
  78. if array.size(_upVIB) > maxVIB
  79. box.delete(array.shift(_upVIB))
  80. array.push(_upVIB, _bullboxVI)
  81.  
  82.  
  83. //Volume Imbalance Down
  84. if showVIB and o < c[1] and o < o[1] and h >= l[1] and c < c[1] and c < o[1]
  85. box _bearboxVI = na
  86. _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))
  87. if array.size(_downVIB) > maxVIB
  88. box.delete(array.shift(_downVIB))
  89. array.push(_downVIB, _bearboxVI)
  90.  
  91.  
  92. _controlBox2(_upVIB,h,l,_fvg)
  93. _controlBox2(_downVIB,h,l,_fvg)
  94.  
  95.  
  96. //Extend VIB
  97. if array.size(_upVIB) > 0 and extendVIB
  98. for i = array.size(_upVIB) - 1 to 0 by 1
  99. _box = array.get(_upVIB, i)
  100. _boxLow = box.get_bottom(_box)
  101. _boxHigh = box.get_top(_box)
  102. _boxRight = box.get_right(_box)
  103. if l > _boxHigh and bar_index == _boxRight
  104. box.set_right(_box, bar_index + 1)
  105. else
  106. if l <= _boxHigh and bar_index == _boxRight and filterVIB
  107. box.set_bgcolor(_box, filterColorVIB)
  108. box.set_border_color(_box, filterColorVIB)
  109.  
  110. //Extend VIB
  111. if array.size(_downVIB) > 0 and extendVIB
  112. for i = array.size(_downVIB) - 1 to 0 by 1
  113. _box = array.get(_downVIB, i)
  114. _boxLow = box.get_bottom(_box)
  115. _boxHigh = box.get_top(_box)
  116. _boxRight = box.get_right(_box)
  117. if h < _boxHigh and bar_index == _boxRight
  118. box.set_right(_box, bar_index + 1)
  119. else
  120. if h >= _boxHigh and bar_index == _boxRight and filterVIB
  121. box.set_bgcolor(_box, filterColorVIB)
  122. box.set_border_color(_box, filterColorVIB)
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement