Advertisement
xmd79

Sudhin Fibonacci Instituitional OB, FVG, BoS, RJB

Jan 10th, 2023
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.03 KB | None | 0 0
  1. //@version=5
  2. //This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  3. indicator('Sudhin Fibonacci Instituitional OB, FVG, BoS, RJB', overlay=true, max_boxes_count=500, max_lines_count=500)
  4.  
  5. plotOB = input.bool(defval=true, title='Plot OB', group='Order Blocks')
  6. obBullColor = input.color(defval=color.new(color.green, 90), title='Bullish OB Color', inline='Set Custom Color', group='Order Blocks')
  7. obBearColor = input.color(defval=color.new(color.red, 90), title='Bearish OB Color', inline='Set Custom Color', group='Order Blocks')
  8. obBoxBorder = input.string(defval=line.style_solid, title='OB Box Border Style', options=[line.style_dashed, line.style_dotted, line.style_solid], group='Order Blocks', tooltip='To disable border, set Border Width below to 0')
  9. obBorderTransparency = input.int(defval=80, title='OB Border Box Transparency', minval=0, maxval=100, group='Order Blocks')
  10. obMaxBoxSet = input.int(defval=10, title='Maximum OB Box Displayed', minval=1, maxval=100, group='Order Blocks', tooltip='Minimum = 1, Maximum = 100')
  11. filterMitOB = input.bool(defval=false, title='Custom Color Mitigated OB', group='Order Blocks')
  12. mitOBColor = input.color(defval=color.new(color.gray, 90), title='Mitigated OB Color', group='Order Blocks', inline='Set Custom Color Mit OB', tooltip='Set Transparency to 0 to make mitigated OB disappear')
  13.  
  14. plotFVG = input.bool(defval=true, title='Plot FVG', group='Fair Value Gaps', inline='FVG sets')
  15. plotStructureBreakingFVG = input.bool(defval=true, title='Plot Structure Breaking FVG', group='Fair Value Gaps', inline='FVG sets')
  16. fvgBullColor = input.color(defval=color.new(color.black, 90), title='Bullish FVG Color', inline='Set Custom Color', group='Fair Value Gaps')
  17. fvgBearColor = input.color(defval=color.new(color.black, 90), title='Bearish FVG Color', inline='Set Custom Color', group='Fair Value Gaps')
  18. fvgStructBreakingColor = input.color(defval=color.new(color.blue, 90), title='Structure Breaking FVG Color', inline='Set Custom Color', group='Fair Value Gaps')
  19. fvgBoxBorder = input.string(defval=line.style_solid, title='FVG Box Border Style', options=[line.style_dashed, line.style_dotted, line.style_solid], group='Fair Value Gaps', tooltip='To disable border, set Border Width below to 0')
  20. fvgBorderTransparency = input.int(defval=80, title='FVG Border Box Transparency', minval=0, maxval=100, group='Fair Value Gaps')
  21. fvgMaxBoxSet = input.int(defval=10, title='Maximum FVG Box Displayed', minval=1, maxval=100, group='Fair Value Gaps', tooltip='Minimum = 1, Maximum = 100')
  22. filterMitFVG = input.bool(defval=false, title='Custom Color Mitigated FVG', group='Fair Value Gaps')
  23. mitFVGColor = input.color(defval=color.new(color.gray, 90), title='Mitigated FVG Color', group='Fair Value Gaps', inline='Set Custom Color Mit FVG', tooltip='Set Transparency to 0 to make mitigated FVG disappear')
  24.  
  25. plotRJB = input.bool(defval=false, title='Plot RJB', group='Rejection Blocks', inline='RJB sets')
  26. rjbBullColor = input.color(defval=color.new(color.green, 90), title='Bullish RJB Color', inline='Set Custom Color', group='Rejection Blocks')
  27. rjbBearColor = input.color(defval=color.new(color.red, 90), title='Bearish RJB Color', inline='Set Custom Color', group='Rejection Blocks')
  28. rjbBoxBorder = input.string(defval=line.style_solid, title='RJB Box Border Style', options=[line.style_dashed, line.style_dotted, line.style_solid], group='Rejection Blocks', tooltip='To disable border, set Border Width below to 0')
  29. rjbBorderTransparency = input.int(defval=80, title='RJB Border Box Transparency', minval=0, maxval=100, group='Rejection Blocks')
  30. rjbMaxBoxSet = input.int(defval=10, title='Maximum RJB Box Displayed', minval=1, maxval=100, group='Rejection Blocks', tooltip='Minimum = 1, Maximum = 100')
  31. filterMitRJB = input.bool(defval=false, title='Custom Color Mitigated RJB', group='Rejection Blocks')
  32. mitRJBColor = input.color(defval=color.new(color.gray, 90), title='Mitigated RJB Color', group='Rejection Blocks', inline='Set Custom Color Mit RJB', tooltip='Set to 100 to make mitigated RJB disappear')
  33.  
  34. plotPVT = input.bool(defval=true, title='Plot Pivots', group='Pivots')
  35. pivotLookup = input.int(defval=1, minval=1, maxval=5,title='Pivot Lookup', group='Pivots', tooltip='Minimum = 1, Maximum = 5')
  36. pvtTopColor = input.color(defval=color.new(color.silver, 0), title='Pivot Top Color', group='Pivots', inline='PVT Color')
  37. pvtBottomColor = input.color(defval=color.new(color.silver, 0), title='Pivot Bottom Color', group='Pivots', inline='PVT Color')
  38.  
  39. plotBOS = input.bool(defval=false, title='Plot BoS', group='Crossovers', inline='BOS sets')
  40. useHighLowForBullishBoS = input.bool(defval=false, title='Use High/Low for Bullish BoS (for Bearish setup)', group='Crossovers')
  41. useHighLowForBearishBoS = input.bool(defval=false, title='Use High/Low for Bearish BoS (for Bullish setup)', group='Crossovers')
  42. bosBoxFlag = input.bool(title='BoS Box Length Manually', defval=false, group='Crossovers', tooltip='If activated the BoS Boxes will not extend unitl crossed by price. Instead will extend by the amount of bars choosen in the "Set BoS Box Length Manually" option')
  43. bosBoxLength = input.int(title='BoS Box Length Manually', defval=3, minval=1, maxval=5, group='Crossovers', inline='BoS Boxes', tooltip='If "Set BoS Box Length Manually" is marked, choose by how many bars. Minimum = 1, Maximum = 5')
  44. bosBullColor = input.color(defval=color.new(color.green, 90), title='Bullish BoS Color', inline='Set Custom Color', group='Crossovers')
  45. bosBearColor = input.color(defval=color.new(color.red, 90), title='Bearish BoS Color', inline='Set Custom Color', group='Crossovers')
  46. bosBoxBorder = input.string(defval=line.style_solid, title='BoS Box Border Style', options=[line.style_dashed, line.style_dotted, line.style_solid], group='Crossovers', tooltip='To disable border, set Border Width below to 0')
  47. bosBorderTransparency = input.int(defval=80, title='BoS Border Box Transparency', minval=0, maxval=100, group='Crossovers')
  48. bosMaxBoxSet = input.int(defval=10, title='Maximum BoS Box Displayed', minval=1, maxval=100, group='Crossovers', tooltip='Minimum = 1, Maximum = 100')
  49.  
  50. plotHVB = input.bool(defval=true, title='Plot HVB', group='High Volume Bar', tooltip='A candle where the average volume is higher than last few bars.')
  51. hvbBullColor = input.color(defval=color.green, title='Bullish HVB Color', inline='Set Custom Color', group='High Volume Bar')
  52. hvbBearColor = input.color(defval=color.red, title='Bearish HVB Color', inline='Set Custom Color', group='High Volume Bar')
  53. hvbEMAPeriod = input.int(defval=12, minval=1, title='Volume EMA Period', group='High Volume Bar')
  54. hvbMultiplier = input.float(defval=1.5, title='Volume Multiplier', minval=1, maxval=100, group='High Volume Bar')
  55.  
  56. plotPPDD = input.bool(defval=true, title="Plot PPDD OB's", group='Qualitative indicators', tooltip='Premium Premium Discount Discount (PPDD) is an OB formed after liquidity sweep. It will show up by default as a triangle (Bull ▲ / Bear ▼). Also PPDD1 (by deafult maked with a x-cross ⨯) which is a weak OB formed after liquidity sweep, that fails to completely engulf the high/low, but closes beyond the trapped candles open price.')
  57. ppddBullColor = input.color(defval=color.new(color.green, 0), title="Bullish PPDD OB's Color", group='Qualitative indicators', inline='PPDD Color')
  58. ppddBearColor = input.color(defval=color.new(color.red, 0), title="Bearish PPDD OB's Color", group='Qualitative indicators', inline='PPDD Color')
  59.  
  60. plotOBFVG = input.bool(defval=true, title='Plot Stacked OB+FVG', group='Qualitative indicators', tooltip='Marks the candle (default with a diamond ◆) when an OB & FVG are stacked, showing momentum')
  61. obfvgBullColor = input.color(defval=color.new(color.green, 0), title='Bullish Stacked OB+FVG Color', group='Qualitative indicators', inline='OBFVG Color')
  62. obfvgBearColor = input.color(defval=color.new(color.red, 0), title='Bearish Stacked OB+FVG Color', group='Qualitative indicators', inline='OBFVG Color')
  63.  
  64. plotLabelOB = input.bool(defval=true, title='Plot OB Label', inline='OB label', group='Label Options')
  65. obLabelColor = input.color(defval=color.gray, title='Color', inline='OB label', group='Label Options')
  66. obLabelSize = input.string(defval=size.tiny, title="Size", options=[size.huge, size.large, size.small, size.tiny, size.auto, size.normal], inline='OB label', group='Label Options')
  67. plotLabelFVG = input.bool(defval=true, title='Plot FVG Label', inline='FVG label', group='Label Options')
  68. fvgLabelColor = input.color(defval=color.gray, title='Color', inline='FVG label', group='Label Options')
  69. fvgLabelSize = input.string(defval=size.tiny, title="Size", options=[size.huge, size.large, size.small, size.tiny, size.auto, size.normal], inline='FVG label', group='Label Options')
  70. plotLabelRJB = input.bool(defval=true, title='Plot RJB Label', inline='RJB label', group='Label Options')
  71. rjbLabelColor = input.color(defval=color.gray, title='Color', inline='RJB label', group='Label Options')
  72. rjbLabelSize = input.string(defval=size.tiny, title="Size", options=[size.huge, size.large, size.small, size.tiny, size.auto, size.normal], inline='RJB label', group='Label Options')
  73. plotLabelBOS = input.bool(defval=true, title='Plot BoS Label', inline='BOS label', group='Label Options')
  74. bosLabelColor = input.color(defval=color.gray, title='Color', inline='BOS label', group='Label Options')
  75. bosLabelSize = input.string(defval=size.tiny, title="Size", options=[size.huge, size.large, size.small, size.tiny, size.auto, size.normal], inline='BOS label', group='Label Options')
  76.  
  77. //Box Types
  78. var int _ob = 1
  79. var int _fvg = 2
  80. var int _rjb = 3
  81. var int _bos = 4
  82.  
  83. //Box Labels
  84. var string _obLabel = "OB"
  85. var string _fvgLabel = "FVG"
  86. var string _rjbLabel = "RJB"
  87. var string _bosLabel = "BoS"
  88. var string _plus = "+"
  89. var string _minus = "-"
  90. var string _empty = ""
  91.  
  92. //Box Arrays
  93. var box[] _bearBoxesOB = array.new_box()
  94. var box[] _bullBoxesOB = array.new_box()
  95. var box[] _bearBoxesFVG = array.new_box()
  96. var box[] _bullBoxesFVG = array.new_box()
  97. var box[] _bearBoxesRJB = array.new_box()
  98. var box[] _bullBoxesRJB = array.new_box()
  99. var box[] _bearBoxesBOS = array.new_box()
  100. var box[] _bullBoxesBOS = array.new_box()
  101.  
  102. //Functions
  103. isUp(index) =>
  104. close[index] > open[index]
  105.  
  106. isDown(index) =>
  107. close[index] < open[index]
  108.  
  109. isObUp(index) =>
  110. isDown(index + 1) and isUp(index) and close[index] > high[index + 1]
  111.  
  112. isObDown(index) =>
  113. isUp(index + 1) and isDown(index) and close[index] < low[index + 1]
  114.  
  115. isFvgUp(index) =>
  116. (low[index] > high[index + 2])
  117.  
  118. isFvgDown(index) =>
  119. (high[index] < low[index + 2])
  120.  
  121. //Function to Calculte Box Length
  122. _controlBox(_boxes, _high, _low, _type) =>
  123. if array.size(_boxes) > 0
  124. for i = array.size(_boxes) - 1 to 0 by 1
  125. _box = array.get(_boxes, i)
  126. _boxLow = box.get_bottom(_box)
  127. _boxHigh = box.get_top(_box)
  128. _boxRight = box.get_right(_box)
  129. if bosBoxFlag and _type == _bos
  130. if na or (bar_index + bosBoxLength - 1 == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
  131. box.set_right(_box, bar_index + bosBoxLength - 1)
  132. else if (filterMitOB and _type == _ob) or (filterMitFVG and _type == _fvg) or (filterMitRJB and _type == _rjb)
  133. if na or (bar_index == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
  134. box.set_right(_box, bar_index + 1)
  135. else
  136. if _type == _ob
  137. box.set_bgcolor(_box, mitOBColor)
  138. box.set_border_color(_box, mitOBColor)
  139. else if _type == _fvg
  140. box.set_bgcolor(_box, mitFVGColor)
  141. box.set_border_color(_box, mitFVGColor)
  142. else if _type == _rjb
  143. box.set_bgcolor(_box, mitRJBColor)
  144. box.set_border_color(_box, mitRJBColor)
  145. else
  146. if na or (bar_index == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
  147. box.set_right(_box, bar_index + 1)
  148.  
  149. //////////////////// Pivots ////////////////////
  150. hih = ta.pivothigh(high, pivotLookup, pivotLookup)
  151. lol = ta.pivotlow(low , pivotLookup, pivotLookup)
  152. top = ta.valuewhen(hih, high[pivotLookup], 0)
  153. bottom = ta.valuewhen(lol, low [pivotLookup], 0)
  154. plot(top, offset=-pivotLookup, linewidth=1, color=(top != top[1] ? na : (plotPVT ? pvtTopColor : na)), title="Pivot Top")
  155. plot(bottom, offset=-pivotLookup, linewidth=1, color=(bottom != bottom[1] ? na : (plotPVT ? pvtBottomColor : na)), title="Pivot Bottom")
  156.  
  157. //////////////////// Order Block //////////////////
  158. //Bullish OB Box Plotting
  159. if isObUp(1) and plotOB
  160. _bullboxOB = box.new(left=bar_index - 2, top=high[2], right=bar_index, bottom=math.min(low[2], low[1]), border_color=color.new(obBullColor, obBorderTransparency), border_style=obBoxBorder, border_width=1, bgcolor=obBullColor,
  161. text=plotLabelOB ? _obLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=obLabelSize, text_color=obLabelColor)
  162. if array.size(_bullBoxesOB) > obMaxBoxSet
  163. box.delete(array.shift(_bullBoxesOB))
  164. array.push(_bullBoxesOB, _bullboxOB)
  165.  
  166. //Bearish OB Box Plotting
  167. if isObDown(1) and plotOB
  168. _bearboxOB = box.new(left=bar_index - 2, top=math.max(high[2], high[1]), right=bar_index, bottom=low[2], border_color=color.new(obBearColor, obBorderTransparency), border_style=obBoxBorder, border_width=1, bgcolor=obBearColor,
  169. text=plotLabelOB ? _obLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=obLabelSize, text_color=obLabelColor)
  170. if array.size(_bearBoxesOB) > obMaxBoxSet
  171. box.delete(array.shift(_bearBoxesOB))
  172. array.push(_bearBoxesOB, _bearboxOB)
  173.  
  174. if plotOB
  175. _controlBox(_bearBoxesOB, high, low, _ob)
  176. _controlBox(_bullBoxesOB, high, low, _ob)
  177.  
  178. //////////////////// Fair Value Gap //////////////////
  179. //Bullish FVG Box Plotting
  180. if isFvgUp(0)
  181. box _bullboxFVG = na
  182. if plotStructureBreakingFVG and (close[1] > top) and (low[1] < top) and (high[2] < top) and (low > top)
  183. _bullboxFVG := box.new(left=bar_index-2, top=low[0], right=bar_index, bottom=high[2], bgcolor=fvgStructBreakingColor, border_color=color.new(fvgStructBreakingColor, fvgBorderTransparency), border_style=fvgBoxBorder, border_width=1,
  184. text=plotLabelFVG ? _fvgLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=fvgLabelSize, text_color=fvgLabelColor)
  185. else if plotFVG
  186. _bullboxFVG := box.new(left=bar_index-2, top=low[0], right=bar_index, bottom=high[2], bgcolor=fvgBullColor, border_color=color.new(fvgBullColor, fvgBorderTransparency), border_style=fvgBoxBorder, border_width=1,
  187. text=plotLabelFVG ? _fvgLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=fvgLabelSize, text_color=fvgLabelColor)
  188. if array.size(_bullBoxesFVG) > fvgMaxBoxSet
  189. box.delete(array.shift(_bullBoxesFVG))
  190. array.push(_bullBoxesFVG, _bullboxFVG)
  191.  
  192. //Bearish FVG Box Plotting
  193. if isFvgDown(0)
  194. box _bearboxFVG = na
  195. if plotStructureBreakingFVG and (close[1] < bottom) and (high[1] > bottom) and (low[2] > bottom) and (high < bottom)
  196. _bearboxFVG := box.new(left=bar_index-2, top=low[2], right=bar_index, bottom=high[0], bgcolor=fvgStructBreakingColor, border_color=color.new(fvgStructBreakingColor, fvgBorderTransparency), border_style=fvgBoxBorder, border_width=1,
  197. text=plotLabelFVG ? _fvgLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=fvgLabelSize, text_color=fvgLabelColor)
  198. else if plotFVG
  199. _bearboxFVG := box.new(left=bar_index-2, top=low[2], right=bar_index, bottom=high[0], bgcolor=fvgBearColor, border_color=color.new(fvgBearColor, fvgBorderTransparency), border_style=fvgBoxBorder, border_width=1,
  200. text=plotLabelFVG ? _fvgLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=fvgLabelSize, text_color=fvgLabelColor)
  201. if array.size(_bearBoxesFVG) > fvgMaxBoxSet
  202. box.delete(array.shift(_bearBoxesFVG))
  203. array.push(_bearBoxesFVG, _bearboxFVG)
  204.  
  205. if plotFVG or plotStructureBreakingFVG
  206. _controlBox(_bearBoxesFVG, high, low, _fvg)
  207. _controlBox(_bullBoxesFVG, high, low, _fvg)
  208.  
  209. //////////////////// Rejection Block //////////////////
  210. if plotRJB
  211. isDownRjbObCondition = isObDown(1)
  212. isDownRjb1 = isDownRjbObCondition and (high[1] < (close[2] + 0.2*(high[2]-close[2]))) // RJB is on trapped's wick and <50% of the wick was covered by signal
  213. isDownRjb2 = isDownRjbObCondition and (high[1] > high[2]) // RJB is on signal's wick
  214. if isDownRjb1 and plotRJB
  215. _bearboxRJB = box.new(left=bar_index-2, top=high[2], right=bar_index, bottom=close[2], bgcolor=rjbBearColor, border_color=color.new(rjbBearColor, rjbBorderTransparency), border_style=rjbBoxBorder, border_width=1,
  216. text=plotLabelRJB ? _rjbLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=rjbLabelSize, text_color=rjbLabelColor)
  217. if array.size(_bearBoxesRJB) > rjbMaxBoxSet
  218. box.delete(array.shift(_bearBoxesRJB))
  219. array.push(_bearBoxesRJB, _bearboxRJB)
  220.  
  221. if isDownRjb2 and plotRJB
  222. _bearboxRJB = box.new(left=bar_index-1, top=high[1], right=bar_index, bottom=open[1], bgcolor=rjbBearColor, border_color=color.new(rjbBearColor, rjbBorderTransparency), border_style=rjbBoxBorder, border_width=1,
  223. text=plotLabelRJB ? _rjbLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=rjbLabelSize, text_color=rjbLabelColor)
  224. if array.size(_bearBoxesRJB) > rjbMaxBoxSet
  225. box.delete(array.shift(_bearBoxesRJB))
  226. array.push(_bearBoxesRJB, _bearboxRJB)
  227.  
  228. //Bullish RJB Box Plotting
  229. if plotRJB
  230. isUpRjbObCondition = isObUp(1)
  231. isUpRjb1 = isUpRjbObCondition and (low[1] > (close[2] - 0.2*(close[2]-low[2]))) // RJB is on trapped's wick and <50% of the wick was covered by signal
  232. isUpRjb2 = isUpRjbObCondition and (low[1] < low[2]) // RJB is on signal's wick
  233. if isUpRjb1 and plotRJB
  234. _bullboxRJB = box.new(left=bar_index-2, top=close[2], right=bar_index, bottom=low[2], bgcolor=rjbBullColor, border_color=color.new(rjbBullColor, rjbBorderTransparency), border_style=rjbBoxBorder, border_width=1,
  235. text=plotLabelRJB ? _rjbLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=rjbLabelSize, text_color=rjbLabelColor)
  236. if array.size(_bullBoxesRJB) > rjbMaxBoxSet
  237. box.delete(array.shift(_bullBoxesRJB))
  238. array.push(_bullBoxesRJB, _bullboxRJB)
  239.  
  240. if isUpRjb2 and plotRJB
  241. _bullboxRJB = box.new(left=bar_index-1, top=open[1], right=bar_index, bottom=low[1], bgcolor=rjbBullColor, border_color=color.new(rjbBullColor, rjbBorderTransparency), border_style=rjbBoxBorder, border_width=1,
  242. text=plotLabelRJB ? _rjbLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=rjbLabelSize, text_color=rjbLabelColor)
  243. if array.size(_bullBoxesRJB) > rjbMaxBoxSet
  244. box.delete(array.shift(_bullBoxesRJB))
  245. array.push(_bullBoxesRJB, _bullboxRJB)
  246.  
  247. if plotRJB
  248. _controlBox(_bearBoxesRJB, high, low, _rjb)
  249. _controlBox(_bullBoxesRJB, high, low, _rjb)
  250.  
  251. //////////////////// Crossovers a.k.a. Break of Structure ////////////////////
  252. //Bullish BOS Box Plotting
  253. if plotBOS
  254. if ta.crossover(useHighLowForBullishBoS ? high : close, top)
  255. _bullboxBOS = box.new(left=bar_index, top=top, right=bosBoxFlag ? bar_index+bosBoxLength : bar_index+1, bottom=bottom, bgcolor=bosBullColor, border_color=color.new(bosBullColor, bosBorderTransparency), border_style=bosBoxBorder, border_width=1,
  256. text=plotLabelBOS ? _bosLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=bosLabelSize, text_color=bosLabelColor)
  257. if array.size(_bullBoxesBOS) > bosMaxBoxSet
  258. box.delete(array.shift(_bullBoxesBOS))
  259. array.push(_bullBoxesBOS, _bullboxBOS)
  260.  
  261. //Bearish BOS Box Plotting
  262. if plotBOS
  263. if ta.crossunder(useHighLowForBearishBoS ? low : close, bottom)
  264. _bearboxBOS = box.new(left=bar_index, top=top, right=bosBoxFlag ? bar_index+bosBoxLength : bar_index+1, bottom=bottom, bgcolor=bosBearColor, border_color=color.new(bosBearColor, bosBorderTransparency), border_style=bosBoxBorder, border_width=1,
  265. text=plotLabelBOS ? _bosLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=bosLabelSize, text_color=bosLabelColor)
  266. if array.size(_bearBoxesBOS) > bosMaxBoxSet
  267. box.delete(array.shift(_bearBoxesBOS))
  268. array.push(_bearBoxesBOS, _bearboxBOS)
  269.  
  270. if plotBOS
  271. _controlBox(_bearBoxesBOS, high, low, _bos)
  272. _controlBox(_bullBoxesBOS, high, low, _bos)
  273.  
  274. //////////////////// Premium Premium & Discount Discount //////////////////
  275. premiumPremium = plotPPDD and isObDown(0) and ((math.max(high, high[1]) > top and close < top) or (math.max(high, high[1]) > top[1] and close < top[1]))
  276. discountDiscount = plotPPDD and isObUp(0) and ((math.min(low, low[1]) < bottom and close > bottom) or (math.min(low, low[1]) < bottom[1] and close > bottom[1]))
  277. plotshape(premiumPremium, "Bearish PPDD OB", style=shape.triangledown , location=location.abovebar, color=ppddBearColor, size=size.tiny)
  278. plotshape(discountDiscount, "Bullish PPDD OB", style=shape.triangleup , location=location.belowbar, color=ppddBullColor, size=size.tiny)
  279.  
  280. premiumPremium1 = plotPPDD and (isUp(1) and isDown(0) and close[0] < open[1]) and ((math.max(high, high[1]) > top and close < top) or (math.max(high, high[1]) > top[1] and close < top[1])) and not premiumPremium
  281. discountDiscount1 = plotPPDD and (isDown(1) and isUp(0) and close[0] > open[1]) and ((math.min(low, low[1]) < bottom and close > bottom) or (math.min(low, low[1]) < bottom[1] and close > bottom[1])) and not discountDiscount
  282. plotshape(premiumPremium1, "Bearish PPDD Weak OB", style=shape.xcross, location=location.abovebar, color=ppddBearColor, size=size.tiny)
  283. plotshape(discountDiscount1, "Bullish PPDD Weak OB", style=shape.xcross, location=location.belowbar, color=ppddBullColor, size=size.tiny)
  284.  
  285. ////////////////// High Volume Bars //////////////////
  286. volEma = ta.ema(volume, hvbEMAPeriod)
  287. isHighVolume = volume > (hvbMultiplier * volEma)
  288. barcolor(plotHVB and isUp(0) and isHighVolume ? hvbBullColor : na, title="Bullish HVB")
  289. barcolor(plotHVB and isDown(0) and isHighVolume ? hvbBearColor : na, title="Bearish HVB")
  290.  
  291. ///////////////// Stacked OB + FVG //////////////////
  292. plotshape(plotOBFVG and isFvgDown(0) and isObDown(1), "Bearish OB+FVG Stack", style=shape.diamond, location=location.abovebar, color=obfvgBearColor, size=size.tiny)
  293. plotshape(plotOBFVG and isFvgUp(0) and isObUp(1), "Bullish OB+FVG Stack", style=shape.diamond, location=location.belowbar, color=obfvgBullColor, size=size.tiny)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement