Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @TRW
- // © VanHelsing
- //@version=5
- indicator('Volume Zone Oscillator by [VanHelsig]', shorttitle='VZO by Van', precision=0, overlay=false)
- // ==================================
- // <===============Inputs=================>
- // ==================================
- int VZO_length = input.int(24, 'VZO Length', minval=2, group = 'VZO')
- int VZO_zone_lower = input.int(70, 'Overbought/sold Lower Limit', minval=0)
- int VZO_zone_upper = input.int(100, 'Overbought/sold Upper Limit', minval=0)
- int VZO_zone_range_Width = input.int(40, 'Range Zone Width', minval=0)
- int VZO_zone_range = input.int(200, 'Range Zone Length', minval=0)
- bool VZO_Intraday = input.bool(true, 'Enable Smoothing')
- int VZO_noise = input.int(9, 'Noise Filter', minval=2)
- string chartResolution = input.timeframe('1D', title='Chart Resolution1_Alert', group = 'Allerts')
- string chartResolution1 = input.timeframe('2D', title='Chart Resolution2_Alert')
- string chartResolution2 = input.timeframe('3D', title='Chart Resolution3_Alert')
- string chartResolution3 = input.timeframe('4D', title='Chart Resolution4_Alert')
- string chartResolution4 = input.timeframe('5D', title='Chart Resolution5_Alert')
- string chartResolution5 = input.timeframe('6D', title='Chart Resolution6_Alert')
- string chartResolution6 = input.timeframe('7D', title='Chart Resolution7_Alert')
- string chartResolution7 = input.timeframe('8D', title='Chart Resolution8_Alert')
- string chartResolution8 = input.timeframe('9D', title='Chart Resolution9_Alert')
- string chartResolution9 = input.timeframe('10D', title='Chart Resolution10_Alert')
- bool repaint = input.bool(true, 'Allow Repainting')
- //Sources
- get_close = close [repaint ? 0 : 1]
- get_vol = volume[repaint ? 0 : 1]
- sym = syminfo.tickerid
- // ==================================
- // <===============Vzo Calc=================>
- // ==================================
- VZO(length, get_close, vol) =>
- Volume_Direction = get_close > get_close[3] ? vol : -vol
- VZO_volume = ta.linreg(Volume_Direction, length,0)
- Total_volume = ta.linreg(vol, length,0)
- 100 * VZO_volume / Total_volume
- VZO_ = VZO(VZO_length, get_close, get_vol)
- //Smoothness (Reduce noise)
- if VZO_Intraday
- VZO_ := ta.ema(VZO_, VZO_noise)
- //ZONE COLORS
- OB_Zone = color.rgb(170, 29, 29, 80)
- OS_Zone = color.rgb(18, 126, 21, 80)
- R_OB_Zone = color.rgb(177, 33, 33, 90)
- R_OS_Zone = color.rgb(26, 143, 30, 90)
- //Webhooks Alerts
- vzo_alerts(tf, sym, vzo)=>
- buy = vzo >= vzo[2]
- request.security(sym, tf, buy) ? 1 : -1
- //10 Days Allerts
- vzo1 = vzo_alerts(chartResolution, sym, VZO_)
- vzo2 = vzo_alerts(chartResolution1, sym, VZO_)
- vzo3 = vzo_alerts(chartResolution2, sym, VZO_)
- vzo4 = vzo_alerts(chartResolution3, sym, VZO_)
- vzo5 = vzo_alerts(chartResolution4, sym, VZO_)
- vzo6 = vzo_alerts(chartResolution5, sym, VZO_)
- vzo7 = vzo_alerts(chartResolution6, sym, VZO_)
- vzo8 = vzo_alerts(chartResolution7, sym, VZO_)
- vzo9 = vzo_alerts(chartResolution8, sym, VZO_)
- vzo10= vzo_alerts(chartResolution9, sym, VZO_)
- //Alert (1-10D)
- alert("VZO " + str.tostring(vzo1) + ' ' + str.tostring(vzo2) + ' ' + str.tostring(vzo3) + ' ' + str.tostring(vzo4) + ' ' + str.tostring(vzo5)
- + ' ' + str.tostring(vzo6) + ' ' + str.tostring(vzo7) + ' ' + str.tostring(vzo8) + ' ' + str.tostring(vzo9) + ' ' + str.tostring(vzo10) + ""
- , alert.freq_once_per_bar)
- // ==================================
- // <=============== Plot =================>
- // ==================================
- //ZONES LEVELS
- //OB
- Red_1 = hline(VZO_zone_upper, linestyle=hline.style_solid, color=color.rgb(202, 39, 39), title = 'Overbought Upper Limit')
- Red_2 = hline(VZO_zone_lower, linestyle=hline.style_solid, color=color.rgb(194, 33, 33), title = 'Overbought Lower Limit')
- fill(Red_1, Red_2, color = OB_Zone, title = 'Overbought Zone')
- //OS
- Green_1 = hline(-VZO_zone_lower, linestyle=hline.style_solid, color=color.green, title = 'Oversold Lower Limit')
- Green_2 = hline(-VZO_zone_upper, linestyle=hline.style_solid, color=color.green, title = 'Oversold Upper Limit')
- fill(Green_1, Green_2, color = OS_Zone, title = 'Oversold Zone')
- //Range zone
- R_1 = ta.sma(VZO_ +VZO_zone_range_Width, VZO_zone_range)
- R_2 = ta.sma(-VZO_-VZO_zone_range_Width, VZO_zone_range)
- plot(R_1, color = color.red, title = 'Upper range')
- plot(R_2, color = color.green, title = 'Lower range')
- hline(0, linestyle=hline.style_dashed, color=color.new(color.white, 50), title = 'Zero Line')
- //Fill OB and OS
- p_vzo_ob = plot( VZO_ > VZO_zone_lower ? VZO_ : VZO_zone_lower, color=na, editable=false)
- p_vzo_os = plot( VZO_ < -VZO_zone_lower ? VZO_ : -VZO_zone_lower, color=na, editable=false)
- p1 = plot( VZO_zone_lower, color=na, editable=false)
- p4 = plot(-VZO_zone_lower, color=na, editable=false)
- fill(p1, p_vzo_ob, color=VZO_ > VZO_zone_lower ? color.rgb(112, 12, 12) : na, title='Overbought fill', transp=40)
- fill(p4, p_vzo_os, color=VZO_ < -VZO_zone_lower ? color.rgb(26, 158, 30) : na, title='Oversold fill', transp=40)
- //Range Zones Plot
- p2 = plot(R_1, color=na, editable=false)
- p8 = plot(R_2, color=na, editable=false)
- fill(p2, p_vzo_ob, color= R_OB_Zone, title='Overbought range fill', transp=80)
- fill(p8, p_vzo_os, color= R_OS_Zone, title='Oversold range fill', transp=80)
- // VZO PLOT
- p_1 = plot(VZO_, 'VZO', color=color.white, style=plot.style_line, linewidth=2)
- //Buy and Sell conditions
- buy_strong = ta.crossover(VZO_, VZO_[1]) and VZO_ < -VZO_zone_lower
- sell_strong = ta.crossunder(VZO_, VZO_[1]) and VZO_ > VZO_zone_lower
- //Buy and Sell signals
- 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)
- 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)
- //Local Buy and Sell
- 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)
- 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)
- //Change of trend
- 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)
- 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)
- // if time > timestamp('2018-01-01')
- // if ta.crossunder(VZO_, VZO_[2])
- // strategy.entry('S', strategy.short)
- // if ta.crossover(VZO_, VZO_[2])
- // strategy.entry('S', strategy.long)
Advertisement
Add Comment
Please, Sign In to add comment