xmd79

Volume Zone Oscillator by [VanHelsig]

Feb 26th, 2023
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.22 KB | None | 0 0
  1. // @TRW
  2. // © VanHelsing
  3.  
  4. //@version=5
  5. indicator('Volume Zone Oscillator by [VanHelsig]', shorttitle='VZO by Van', precision=0, overlay=false)
  6. // ==================================
  7. // <===============Inputs=================>
  8. // ==================================
  9.  
  10. int VZO_length = input.int(24, 'VZO Length', minval=2, group = 'VZO')
  11. int VZO_zone_lower = input.int(70, 'Overbought/sold Lower Limit', minval=0)
  12. int VZO_zone_upper = input.int(100, 'Overbought/sold Upper Limit', minval=0)
  13. int VZO_zone_range_Width = input.int(40, 'Range Zone Width', minval=0)
  14. int VZO_zone_range = input.int(200, 'Range Zone Length', minval=0)
  15. bool VZO_Intraday = input.bool(true, 'Enable Smoothing')
  16. int VZO_noise = input.int(9, 'Noise Filter', minval=2)
  17.  
  18. string chartResolution = input.timeframe('1D', title='Chart Resolution1_Alert', group = 'Allerts')
  19. string chartResolution1 = input.timeframe('2D', title='Chart Resolution2_Alert')
  20. string chartResolution2 = input.timeframe('3D', title='Chart Resolution3_Alert')
  21. string chartResolution3 = input.timeframe('4D', title='Chart Resolution4_Alert')
  22. string chartResolution4 = input.timeframe('5D', title='Chart Resolution5_Alert')
  23. string chartResolution5 = input.timeframe('6D', title='Chart Resolution6_Alert')
  24. string chartResolution6 = input.timeframe('7D', title='Chart Resolution7_Alert')
  25. string chartResolution7 = input.timeframe('8D', title='Chart Resolution8_Alert')
  26. string chartResolution8 = input.timeframe('9D', title='Chart Resolution9_Alert')
  27. string chartResolution9 = input.timeframe('10D', title='Chart Resolution10_Alert')
  28.  
  29. bool repaint = input.bool(true, 'Allow Repainting')
  30.  
  31. //Sources
  32. get_close = close [repaint ? 0 : 1]
  33. get_vol = volume[repaint ? 0 : 1]
  34. sym = syminfo.tickerid
  35.  
  36. // ==================================
  37. // <===============Vzo Calc=================>
  38. // ==================================
  39. VZO(length, get_close, vol) =>
  40. Volume_Direction = get_close > get_close[3] ? vol : -vol
  41. VZO_volume = ta.linreg(Volume_Direction, length,0)
  42. Total_volume = ta.linreg(vol, length,0)
  43. 100 * VZO_volume / Total_volume
  44.  
  45. VZO_ = VZO(VZO_length, get_close, get_vol)
  46.  
  47. //Smoothness (Reduce noise)
  48. if VZO_Intraday
  49. VZO_ := ta.ema(VZO_, VZO_noise)
  50.  
  51. //ZONE COLORS
  52. OB_Zone = color.rgb(170, 29, 29, 80)
  53. OS_Zone = color.rgb(18, 126, 21, 80)
  54.  
  55. R_OB_Zone = color.rgb(177, 33, 33, 90)
  56. R_OS_Zone = color.rgb(26, 143, 30, 90)
  57.  
  58. //Webhooks Alerts
  59. vzo_alerts(tf, sym, vzo)=>
  60. buy = vzo >= vzo[2]
  61. request.security(sym, tf, buy) ? 1 : -1
  62.  
  63. //10 Days Allerts
  64. vzo1 = vzo_alerts(chartResolution, sym, VZO_)
  65. vzo2 = vzo_alerts(chartResolution1, sym, VZO_)
  66. vzo3 = vzo_alerts(chartResolution2, sym, VZO_)
  67. vzo4 = vzo_alerts(chartResolution3, sym, VZO_)
  68. vzo5 = vzo_alerts(chartResolution4, sym, VZO_)
  69. vzo6 = vzo_alerts(chartResolution5, sym, VZO_)
  70. vzo7 = vzo_alerts(chartResolution6, sym, VZO_)
  71. vzo8 = vzo_alerts(chartResolution7, sym, VZO_)
  72. vzo9 = vzo_alerts(chartResolution8, sym, VZO_)
  73. vzo10= vzo_alerts(chartResolution9, sym, VZO_)
  74.  
  75. //Alert (1-10D)
  76. alert("VZO " + str.tostring(vzo1) + ' ' + str.tostring(vzo2) + ' ' + str.tostring(vzo3) + ' ' + str.tostring(vzo4) + ' ' + str.tostring(vzo5)
  77. + ' ' + str.tostring(vzo6) + ' ' + str.tostring(vzo7) + ' ' + str.tostring(vzo8) + ' ' + str.tostring(vzo9) + ' ' + str.tostring(vzo10) + ""
  78. , alert.freq_once_per_bar)
  79.  
  80. // ==================================
  81. // <=============== Plot =================>
  82. // ==================================
  83. //ZONES LEVELS
  84. //OB
  85. Red_1 = hline(VZO_zone_upper, linestyle=hline.style_solid, color=color.rgb(202, 39, 39), title = 'Overbought Upper Limit')
  86. Red_2 = hline(VZO_zone_lower, linestyle=hline.style_solid, color=color.rgb(194, 33, 33), title = 'Overbought Lower Limit')
  87. fill(Red_1, Red_2, color = OB_Zone, title = 'Overbought Zone')
  88. //OS
  89. Green_1 = hline(-VZO_zone_lower, linestyle=hline.style_solid, color=color.green, title = 'Oversold Lower Limit')
  90. Green_2 = hline(-VZO_zone_upper, linestyle=hline.style_solid, color=color.green, title = 'Oversold Upper Limit')
  91. fill(Green_1, Green_2, color = OS_Zone, title = 'Oversold Zone')
  92.  
  93. //Range zone
  94. R_1 = ta.sma(VZO_ +VZO_zone_range_Width, VZO_zone_range)
  95. R_2 = ta.sma(-VZO_-VZO_zone_range_Width, VZO_zone_range)
  96. plot(R_1, color = color.red, title = 'Upper range')
  97. plot(R_2, color = color.green, title = 'Lower range')
  98. hline(0, linestyle=hline.style_dashed, color=color.new(color.white, 50), title = 'Zero Line')
  99.  
  100. //Fill OB and OS
  101. p_vzo_ob = plot( VZO_ > VZO_zone_lower ? VZO_ : VZO_zone_lower, color=na, editable=false)
  102. p_vzo_os = plot( VZO_ < -VZO_zone_lower ? VZO_ : -VZO_zone_lower, color=na, editable=false)
  103.  
  104. p1 = plot( VZO_zone_lower, color=na, editable=false)
  105. p4 = plot(-VZO_zone_lower, color=na, editable=false)
  106.  
  107. fill(p1, p_vzo_ob, color=VZO_ > VZO_zone_lower ? color.rgb(112, 12, 12) : na, title='Overbought fill', transp=40)
  108. fill(p4, p_vzo_os, color=VZO_ < -VZO_zone_lower ? color.rgb(26, 158, 30) : na, title='Oversold fill', transp=40)
  109.  
  110. //Range Zones Plot
  111. p2 = plot(R_1, color=na, editable=false)
  112. p8 = plot(R_2, color=na, editable=false)
  113. fill(p2, p_vzo_ob, color= R_OB_Zone, title='Overbought range fill', transp=80)
  114. fill(p8, p_vzo_os, color= R_OS_Zone, title='Oversold range fill', transp=80)
  115.  
  116. // VZO PLOT
  117. p_1 = plot(VZO_, 'VZO', color=color.white, style=plot.style_line, linewidth=2)
  118.  
  119. //Buy and Sell conditions
  120. buy_strong = ta.crossover(VZO_, VZO_[1]) and VZO_ < -VZO_zone_lower
  121. sell_strong = ta.crossunder(VZO_, VZO_[1]) and VZO_ > VZO_zone_lower
  122.  
  123. //Buy and Sell signals
  124. plotshape(sell_strong ? VZO_ : na, title='Sell Strong', style = shape.triangledown, location=location.top , text = '', textcolor = color.red, size=size.tiny, color=color.new(#b41b1b, 0), offset = -1)
  125. plotshape(buy_strong ? VZO_ : na, title='Buy Strong', style = shape.triangleup, location=location.bottom , text = '', textcolor = color.green, size=size.tiny, color=color.rgb(20, 148, 24), offset = -1)
  126. //Local Buy and Sell
  127. plotshape(ta.crossunder(VZO_, VZO_[2]) ? VZO_ : na, title='Local Sell', style = shape.diamond, location=location.absolute, text = '', textcolor = color.white, size=size.small, color=color.new(#b41b1b, 0), offset = 0)
  128. plotshape(ta.crossover(VZO_, VZO_[2]) ? VZO_ : na, title='Local Buy', style = shape.diamond, location=location.absolute, text = '', textcolor = color.white, size=size.small, color=color.rgb(20, 148, 24), offset = 0)
  129. //Change of trend
  130. plotchar(ta.crossover(VZO_, R_1) ? VZO_ : na, char = '', title='Change of the trend (overbought zone)', location=location.absolute, text = '🔷', textcolor = color.white, size=size.tiny,color=color.rgb(20, 148, 24), offset = 0)
  131. plotchar(ta.crossunder(VZO_, R_2) ? VZO_ : na, char = '🔹', title='Change of the trend (oversold zone)', location=location.bottom, text = '', textcolor = color.white, size=size.tiny, color=color.rgb(20, 148, 24), offset = 0)
  132.  
  133.  
  134. // if time > timestamp('2018-01-01')
  135. // if ta.crossunder(VZO_, VZO_[2])
  136. // strategy.entry('S', strategy.short)
  137. // if ta.crossover(VZO_, VZO_[2])
  138. // strategy.entry('S', strategy.long)
Advertisement
Add Comment
Please, Sign In to add comment